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

Including gl.h in multiples cpp files

Started by Trillian Jul 11, 2006 at 3:16 PM 3 replies 600+ views
Original Post
Trillian
Trillian
Hello! After almost a year with directx i'm starting to switch back to opengl. I'm currently creating a library to wrap up some opengl functionalities. The problem I'm having is that I cannot #include "gl/gl.h" in different .cpp files because I get an unlimited amount of "redefenition errors". I'd like to know how to proceed to be able tu have gl.h included in many cpp files. This question is not really API-specific but I never had the same problem when including other headers in multiple cpp files. Thanks!
nullsquared
nullsquared
Make sure you have include guards on all headers that include gl (although there should be include guards on every other header too), and make sure you're not including an .cpp files directly into another .cpp.
Trillian
Trillian
I'm not doing any of those things. Here's a schema :

+-FEGL (my library, links to gl32.lib and glu32.lib)   |   +--Device.h   (Has include guards)   +--Device.cpp (includes Device.h and gl/gl.h)   +--Sprite.h   (Has include guards)   +--Sprite.cpp (includes Sprite.h and gl/gl.h)   +--Functions.h   (Has include guards)   +--Functions.cpp (includes Functions.h and gl/gl.h)


Any other ideas?
Trillian
Trillian
In fact, the errors are all related to APIENTRY and WINGDIAPI as being undefined, I've seen that glew.h defines them, do I need to always include glew.h before gl.h?

Topic Locked

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

Sign in to reply to this topic.