Dev-C++ defining #ifndef out of hpp/cpp files

Started by
3 comments, last by Zeophlite 16 years ago
Alright, so I'm using OGLFT for text in my game, and in OGLFT.h, there are these lines: #ifndef OGLFT_NO_SOLID #include <GL/gle.h> #endif #ifndef OGLFT_NO_QT #include <qstring.h> #include <qcolor.h> #endif On my system, I do not have QT or gle, so I want to define OGLFT_NO_QT and OGLFT_NO_SOLID. Now while I could just define those above the #ifndef OGLFT_NO_SOLID line, i.e. #define OGLFT_NO_SOLID #define OGLFT_NO_QT #ifndef OGLFT_NO_SOLID ... I don't want to do that, because it means I have to modify the OGLFT code, and if I wanted to update to the next version, I would have to remodify the code again. Also, I think thats against the license for it (GPL?) The readme file that comes with it suggests that I call: ./configure --disable-solid or ./configure --disable-qt However, these seem to be Linux "thingos" Instead, I've been copying OGLFT.h and OGLFT.cpp from the archieve, then editing OGLFT.h with the defines, and stated above. I don't want to do this, because of the reasons above. I'm using Dev-C++ for my coding. Thankyou for your assistance, Daniel
Advertisement
I believe you have two options to solve this differently.
You can either define those defines on the compiler's command line, i. e. pass -DOGLFT_NO_QT to g++. You can set this somewhere in dev-cpp's project settings under something like "compiler command-line options" (probably called differently).
Or you can just define your defines before you include OGLFT.h, but that wouldn't affect that .cpp-file.
Hi,

the solution to your problem lies in a simple fact: preprocessor directives aren't limited in effect to the file they're defined in. They affect all the code coming after them, be it in the same file or included. So what you could do is #define OGLFT_NO_QT before you include OGLFT.h.

An even better solution would be to find where DEV C++ allows you to define preprocessor constants globally for your project, and do it there. This would guarantee that the constant is defined before you include the header. I've never used DEV C++ so I cannot help you with locating this setting, but it has to exist, so search around.
You can also have a look at the configure script and try to figure out what it adds to the makefile...
Thankyou for your quick response

Quote:Original post by jkuhlmann
Or you can just define your defines before you include OGLFT.h, but that wouldn't affect that .cpp-file.

The defines are also referenced in the cpp files, so that won't work. I'll have a look at your other option

@kiwibonga and Morrandir
I'll have a look

edit: Turns out there is, Project->Project Options->Parameters->C++ compiler
I added these lines:
-DOGLFT_NO_QT=1
-DOGLFT_NO_SOLID=1


[Edited by - Zeophlite on April 20, 2008 6:45:11 AM]

This topic is closed to new replies.

Advertisement