Skip to main content
GameDev.net gamedev.net
🔒 Locked

windows and dev-cpp

Started by petercnm Feb 24, 2005 at 1:30 PM 4 replies 1k views
Original Post
petercnm
petercnm
i have this problem.... I have a WIN32GUI project in dev-cpp with 3 files: winmain.cpp, cgfxopengl.cpp and cgfxopengl.h. In cgfxopengl.cpp i cannot use windowsfunctions like PostQuitMessage, MessageBox ....(work in winmain.cpp). Any suggestions anyone ? Thanks Peter
Evil Steve
Evil Steve
Have you doe #include in cgfxopengl.cpp or a header that is included by it?
petercnm
petercnm
i included windows.h in cgfxopengl.h and it works now, but could you maybe tell me why ? (i included windows.h in cgfxopengl.cpp).

Thanks very much.
Evil Steve
Evil Steve
The compiler only deals with one .cpp file at a time. It forgets everything it saw in any other cpp file. So if you include windows.h in winmain.cpp, the compiler compiles it and reads windows.h where it finds the definitons of PostQuitMessage and so on.
Then it compiles cgfxopengl.cpp, and it comes across PostQuitMessage(). However, it doesn't know what this is (it hasn't seen it declared before because you haven't included windows.h, and it doesn't know about winmain.cpp), so it gives you an error.

The compiler only compiles one .cpp file at a time. The linker puts all the parts together into one executable file.
petercnm
petercnm
Again, thanks very much.

Peter

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.