Exit error

This is a discussion on Exit error within the C++ Programming forums, part of the General Programming Boards category; Hello, Appears this error when i compile the program Error 1 error C2381: 'exit' : redefinition; __declspec(noreturn) differs c:\program files\microsoft ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    21

    Exit error

    Hello,

    Appears this error when i compile the program

    Error 1 error C2381: 'exit' : redefinition; __declspec(noreturn) differs c:\program files\microsoft visual studio 8\vc\include\stdlib.h 406


    Anyone know why this append?

    Thanks

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,632
    I suggest posting the smallest and simplest program that demonstrates the error.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    21
    I have 9 classes and i don´t know where comes the error because is in stdlib.h i can show the line in stdlib.h

    #ifndef _CRT_TERMINATE_DEFINED
    #define _CRT_TERMINATE_DEFINED
    _CRTIMP __declspec(noreturn) void __cdecl exit(__in int _Code);
    _CRTIMP __declspec(noreturn) void __cdecl _exit(__in int _Code);
    _CRTIMP void __cdecl abort(void);
    #endif

    but i think that it doesn't help

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    My guess is that you have ANOTHER declaration or definition of the function exit(), which doesn't have "declspec(noreturn)" on it. If you have a function called exit, then you shouldn't - because it's a standard function [unless you are writing your own OS, in which case you probably shouldn't be using MS's standard header files].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    21
    i haven't another declaration or definition os the function exit() this is why i don't know where the error comes from

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The error you have clearly states "redefinition", so I'm 99.9% sure that the compiler is seeing another declaration or definition of the function exit somewhere.

    You may find that compiling the source through only the preprocessor stage, which gives you the entire source code, and searching for "exit", will help here.

    Edit: alternatively, start cropping your file to bits until you have a small sample, using only standard header files, that you can post here - it shouldn't require more than a few dozen lines, I would expect. [And then, perhaps, use the preprocessor stage output to analyze what is going on].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,632
    Well, what is the program in question? Try and simplify the program to come up with the smallest and simplest program that demonstrates the error.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Registered User
    Join Date
    Jan 2008
    Posts
    21
    "You may find that compiling the source through only the preprocessor stage, which gives you the entire source code, and searching for "exit", will help here." how i can access that?

    Laserlight is an OpenGL program and i don't know where the error comes from so i can't simplify the program. i guess

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by skiler View Post
    "You may find that compiling the source through only the preprocessor stage, which gives you the entire source code, and searching for "exit", will help here." how i can access that?

    Laserlight is an OpenGL program and i don't know where the error comes from so i can't simplify the program. i guess
    If you are using Visual Studio, you should be able to get the "compiler command" in your console window, and then replace the /c with /E to produce the preprocessed output.

    To reduce the code, just put #if 0/#endif around large portions of your code [or cut out large portions of code], then "correct" all the errors you get by removing the calls to the functions you have now removed. [Making empty functions first would be another way].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Jan 2008
    Posts
    21
    1>c:\program files\microsoft visual studio 8\vc\include\stdlib.h(406) : error C2381: 'exit' : redefinition; __declspec(noreturn) differs
    1> c:\program files\microsoft visual studio 8\vc\include\gl\glut.h(146) : see declaration of 'exit'
    1>Textura.cpp
    1>c:\program files\microsoft visual studio 8\vc\include\stdlib.h(406) : error C2381: 'exit' : redefinition; __declspec(noreturn) differs
    1> c:\program files\microsoft visual studio 8\vc\include\gl\glut.h(146) : see declaration of 'exit'


    You are talking about this? i'm a little lost

  11. #11
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Ah, right, so glut.h contains another definition of exit. You probably don't even want that one.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  12. #12
    Registered User
    Join Date
    Jan 2008
    Posts
    21
    but glut.h is an api to openGL, so is standard i use them in other programs and never appear this error :|

  13. #13
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by skiler View Post
    but glut.h is an api to openGL, so is standard i use them in other programs and never appear this error :|
    You are probably not including stdlib.h in the same file - which is really what glut.h should do, but probably for portability reasons DOESN'T [And yes, I know what the file is - I'm working with OpenGLES and OpenVG at the moment].

    Try removing [commenting out] the exit declaration in glut.h, and see if that works for you.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  14. #14
    Registered User
    Join Date
    Jan 2008
    Posts
    21
    doesn't work :|

    Error 1 error C2065: 'exit' : undeclared identifier c:\program files\microsoft visual studio 8\vc\include\gl\glut.h 486
    Error 2 error C2365: 'exit' : redefinition; previous definition was 'formerly unknown identifier' c:\program files\microsoft visual studio 8\vc\include\stdlib.h 406


    this errors appears

  15. #15
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You can solve both of those by including "stdlib" ahead of glut.h [or inside glut.h, which is probably how it really should be ANYWAYS].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  2. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  4. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 06:17 PM
  5. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21