0

I'm writing a GUI to an application, but the main developer wants to set in Makefile if the GUI get or not compiled with the rest. I'm putting all the GTK+ code in a separated file, but in the main file I need to test if the application is being compiled with the GUI or not, so how I can test this?

E.g:

if(COMPILED_WITH_GTK)
    #include "my_gtk_stuffs.h"
Frederico Schardong
  • 1,946
  • 6
  • 38
  • 62

1 Answers1

2

Assuming that COMPILED_WITH_GTK is an argument to the compiler command in the Makefile (in the form of -DCOMPILED_WITH_GTK) you use a preprocessor directive.

#ifdef COMPILED_WITH_GTK
#include "my_gtk_stuffs.h"
#endif

This tells the preprocessor to only process the #include statement if COMPILED_WITH_GTK is defined.

Have a look here, as well.

David Alber
  • 17,624
  • 6
  • 65
  • 71
  • @user1129682 Thanks for pointing that out. You might be able to guess what I have been programming in lately due to that. – David Alber May 20 '12 at 17:19