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"
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.This tells the preprocessor to only process the
#include
statement ifCOMPILED_WITH_GTK
is defined.Have a look here, as well.