Hi,
I'm trying to build an old code (main.cpp) where I'm using SDL. This is my first time using Visual Studio 2005.
I have included the following:
#include
<SDL/SDL.h>#include
<stdio.h>#include
<stdlib.h>
int
main(int argc, char *argv[]){
if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 ) //SDL_Init will return -1 if it could not initialize{
printf(
"Unable to init SDL: %s\n", SDL_GetError());exit(1);
}
atexit(SDL_Quit);
}
I get the error : error C3861: 'exit': identifier not found.
What am I doing wrong

error C3861: 'exit': identifier not found
Jurgen
No,
get the same error:
a.ccp(5) : error c3861: 'exit': identifier not found.
Sherley Lee
That is very strange.
The following compiles perfectly with VC++ 2005 :
#include <stdlib.h>
int main()
{
exit(0);
}
Could you try compiling the above code snippet
Ken Hizer
Put the code into a cpp file (say a.cpp)
#include <stdlib.h>
int main()
{
exit(0);
}
And compile from the command line. Use cl a.cpp
Does that work
rgallazzi
iffi raja
Use the Visual Studio 2005 Command Prompt.
Alberto Grasso
I tried to understand the main.i file, but didn't ...
then I looked through the stdlib.h file, and found the the following line was commended out:
_CRTIMP
__declspec(noreturn) void __cdecl exit(__in int _Code);I took out the comment and recompiled it ... and now it works.
Thank you both for your help
Pranky
Another technique is to generate a preprocessor output file for the cpp file being compiled. Under C/C++ settings, set the Generate Preprocessed File (/P) to Yes. Then look for the definition of exit(). If it is isn't there, then compare with stdlib.h to see how it might have been #ifdef'd out.
Brian
MSpencer
Hi Nishant.
I tried compiling the above snipplet, but got the same error.
When I create the new project I make it as a Windows 32 Console Application.
Zone
Udi Dahan
Brian,
I get a LINK error, when I try this ...
cannot open file '.\Debug\main.obj'
dlevy1
No,
I'm not able to compile from the command line ... 'cl' is not recognized.