Help on the order of #includes in C++

W

Webster

Hello,

I am having a problem with the order of the #includes in C++. When I
compile it in VC++ 6.0 it gives me no problems, but when I try it out in
VS.NET, it gives me a redefinition error:

c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\stdlib.h(251):
error C2381: 'exit' : redefinition; __declspec(noreturn) differs

So I tried different orders of the includes, but no matter if I include the
<windows.h> first or the <stdlib.h> first, it always complains. Please note
that this is not my code, but I am supposed to use it as "helpful" template
code. Can anyone shed some light on the subject???

Thanks. See below for my #includes.

--
Regards,
Webster



Original Code:
---------------
#ifdef WIN32
#include <windows.h>
#endif

#include <GL/gl.h>
#include <GL/glu.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>

#include <iostream.h>

The way I currently have:
--------------------------
#ifdef WIN32
#include <windows.h>
#endif

//#include <iostream.h>
//#include <stdio.h>
//#include <math.h>
//#include <stdlib.h> <--- commented this out because i suspected that
the <windows.h> file should have defined exit

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
 
B

Bruno van Dooren

I am not sure that i can solve your problem, but i have had problems with
standard include files.
It turned out that i did not need to put '.h' in the name of the include
file:

use
#include <string>
instead of
#include <string.h>

but as i said i don't know if this is the cause of your problem.

kind regards,
Bruno.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top