Hi
The exit() function is belong to the stdlib.h that is a standard library. Why
when I use it without include this header the the dev-c++ does not throw any
error?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You are using the C compiler, gcc, instead of the C++ compiler, g++
Changing the program extension from .c to .cpp. will use C++ and give the
error.
With mingw C, exit is also a built-in function.
When I compile with a newer version of the gcc compiler I get the warning:
devcpp.c: In function 'main':
devcpp.c:4:2: warning: implicit declaration of function 'exit'
devcpp.c:4:2: warning: incompatible implicit declaration of built-in function
'exit'
Including the header file eliminates the warning.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The compiler is ANSI compatible.
All compiler have additions to ANSI and their own way of implementing ANSI
standards.
The compilers may be different even though they are all ANSI compliant.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
The exit() function is belong to the stdlib.h that is a standard library. Why
when I use it without include this header the the dev-c++ does not throw any
error?
Thanks
What other files have you included?
stdlib.h could be included in another file.
Only stdio.h
But according to the ANSI standard library the exit function belongs to the
stdlib.h!
Post your source code and the compile log.
include <stdio.h>
int main(void)
{
exit(0);
return 0;
}
You didn't post the compile log.
When I compile I get::
devcpp.cpp: In function 'int main()':
devcpp.cpp:4:8: error: 'exit' was not declared in this scope
Compiler: Default compiler
Executing gcc.exe...
gcc.exe "C:\Users\me\Desktop\Untitled1.c" -o
"C:\Users\me\Desktop\Untitled1.exe" -g3 -I"C:\Dev-Cpp\include" -L"C:\Dev-
Cpp\lib" -g3
Execution terminated
Compilation successful
You are using the C compiler, gcc, instead of the C++ compiler, g++
Changing the program extension from .c to .cpp. will use C++ and give the
error.
With mingw C, exit is also a built-in function.
When I compile with a newer version of the gcc compiler I get the warning:
devcpp.c: In function 'main':
devcpp.c:4:2: warning: implicit declaration of function 'exit'
devcpp.c:4:2: warning: incompatible implicit declaration of built-in function
'exit'
Including the header file eliminates the warning.
Thank you....although I have a question about the compatibility of gcc to
ANSI. Not compatible with ANSI?
The compiler is ANSI compatible.
All compiler have additions to ANSI and their own way of implementing ANSI
standards.
The compilers may be different even though they are all ANSI compliant.