Gcc error when calling exit(-1) in a .c file


 
Thread Tools Search this Thread
Top Forums Programming Gcc error when calling exit(-1) in a .c file
# 1  
Old 01-10-2013
Gcc error when calling exit(-1) in a .c file

gcc is giving me an error when calling exit(-1) in xbuplot.c

Code:
cd ../pltlib; make xbuplot.o
make[1]: Entering directory `/media/ios120/chrisd/research/fast-zb/fast/pltlib'
gcc -c -o xbuplot.o xbuplot.c
xbuplot.c: In function ‘xbuinit_':
xbuplot.c:171:5: warning: incompatible implicit declaration of built-in function ‘exit' [enabled by default]
xbuplot.c:214:5: warning: incompatible implicit declaration of built-in function ‘exit' [enabled by default]
xbuplot.c:219:5: warning: incompatible implicit declaration of built-in function ‘exit' [enabled by default]
xbuplot.c:246:5: warning: incompatible implicit declaration of built-in function ‘exit' [enabled by default]
xbuplot.c: In function ‘xbuevent_':
xbuplot.c:694:9: error: a label can only be part of a statement and a declaration is not a statement
make[1]: *** [xbuplot.o] Error 1
make[1]: Leaving directory `/media/ios120/chrisd/research/fast-zb/fast/pltlib'
make: *** [../pltlib/xbuplot.o] Error 2

# 2  
Old 01-10-2013
You need to paste the source or its hard to understand what is happening there just from errors.
# 3  
Old 01-10-2013
Fixed by including

Code:
#include <stdlib.h>

# 4  
Old 01-10-2013
exit(-1) makes no sense. You're supposed to give it a number from 0 to 255. Anything other than 0 means error.
# 5  
Old 01-10-2013
Quote:
Originally Posted by Corona688
exit(-1) makes no sense. You're supposed to give it a number from 0 to 255. Anything other than 0 means error.
The use of exit(-1) seems to come from the Microsoft world. Unfortunately I now see it frequently in Linux source code. On Linux, exit(-1) returns 255, as under the hood GCC logically ANDs the -1 with 0xff.
# 6  
Old 01-11-2013
You need to include stdlib.h. The compiler is complaining that it hasn't seen a prototype for exit() before you used it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

gcc compiling error

I am using gcc to compile c objects on solaris 5.10 and hit the following error messages: /usr/include/sys/vfs.h:323: error: syntax error before "statvfs64_t" /usr/include/sys/vfs.h:334: error: syntax error before "statvfs64_t" gmake: *** Error 1 The c program files were copied over from... (3 Replies)
Discussion started by: med7006
3 Replies

2. Shell Programming and Scripting

how to exit out of the calling Shell Script

Hi All, I tried looking for this, but was not able to get a clear answer. Hence posting here. Please find the details below. Thanks for the help I have 2 shell scripts, script1.sh and script2.sh. I call script2.sh from within script1.sh ( by simple ./script2.sh command). Based on some... (7 Replies)
Discussion started by: harimac
7 Replies

3. UNIX for Advanced & Expert Users

GCC 4 error.

Hello, dont know much about C, or gcc, but I am trying to compile a program that built fine in gcc3, but is outputting errors in gcc4, int load_REs(char *, char ); #this line is causing the error DB_Query.h:22: error: array type has incomplete element type any help would be appreciated. (3 Replies)
Discussion started by: mike171562
3 Replies

4. Linux

tar error exit delayed form pervious error

Hi when use "tar cpvzf /dev/st0 --exclude=/proc --exclude-/lost+found --exclude=/mnt --exclude=/media --exclude=/sys /" to tape, get the following message "tar: error exit delayed form pervious error", What is the mean ? Please suggest some solution for these errors. thx (1 Reply)
Discussion started by: chayato
1 Replies

5. Solaris

Installing gcc - recieve error message gcc : cannot execute

AIM- Install Oracle 11g on Solaris using VMWare Steps 1.Logged on as root 2.Created subfolders à /usr/local/bin & /usr/local/bin/gcc 3.Downloaded gcc & libiconv & unzipped them on my harddrive & burnt them on CD 4.Copied files from CD to /usr/local/bin/gcc 5.Terminal (root) à pkgadd -d... (8 Replies)
Discussion started by: Ackers
8 Replies

6. Shell Programming and Scripting

Passing exit code to calling script

In production I need to pass an exit code from a script that is being called 3 or 4 layers deep. I've created test scripts to play with it until I get it right. As you can tell, this is not my normal job. Perhaps I should have entered this in UNIX for Dummies section. Anyway, I keep losing the... (2 Replies)
Discussion started by: debbiekuch
2 Replies

7. Linux

gcc install error

I download a gcc3.0.tar.gz file ,then tar it. Continue,I change current path to gcc3.0 and press ./configure The error appeared ,it is CC command not found . Please tell me What can I do to pass on. (1 Reply)
Discussion started by: fansings
1 Replies

8. AIX

RS/6000 gcc compile large file error

hi, everybody£º i have a question, pls help me¡£ OS : RS/6000 AIX 4.3.3 cPU : Powerpc,POWER3 compiler : gcc 3.2.3 source file £º 8M OS kernel : 32 bit (selecting at installing operating system, the hardware support 64 bit) when i compiling the large source file (8 M), i... (3 Replies)
Discussion started by: q30
3 Replies

9. Programming

Error in compile C by gcc

Hi all, I compile my c program and get following result hrnpfc01.c:1387: stray '\' in program hrnpfc01.c:1387: parse error before `,' hrnpfc01.c:1388: stray '\' in program hrnpfc01.c:1388: parse error before `,' hrnpfc01.c:1396: stray '\' in program hrnpfc01.c:1396: parse error before... (4 Replies)
Discussion started by: zico
4 Replies

10. Shell Programming and Scripting

Error in gcc

Hi:- I am new for Unix and wants to install gcc compiler on my Linux system. I donwload the file and tried to install it but getting following messaged, # ./configure Configuring for a i686-pc-linux-gnuoldld host. Created "Makefile" in /home/gcc-3.0.1 using "mt-frag" ./configure: cc: command... (6 Replies)
Discussion started by: s_aamir
6 Replies
Login or Register to Ask a Question