ekarem
ekarem

Reputation: 148

C++ parameterized header inclusion

I'm working on an image processing project, and have created many libraries for different feature extraction methods. I have also another library that uses one of these libraries.

I don't want to include all of them, so I would like to selectively include libraries based on parameters defined by a config file. The config file stores the parameter and its value as shown below:

lib: "a"

Is it possible to selectively include "library a" by reading the parameters in from this config file?

Upvotes: 1

Views: 208

Answers (1)

manuelbcd
manuelbcd

Reputation: 4527

You can include conditionals in compilation time with #ifdef #ifndef #endif directives

#define TypeA
#define TypeB


#ifdef TypeA
#include <lib.h>
#endif

#ifdef TypeB
#include <stdio.h>
#endif

Upvotes: 1

Related Questions