简体   繁体   English

C ++参数化标头包含

[英]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" lib:“一个”

Is it possible to selectively include "library a" by reading the parameters in from this config file? 是否可以通过从此配置文件中读取参数来选择性地包括“库a”?

You can include conditionals in compilation time with #ifdef #ifndef #endif directives 您可以使用#ifdef #ifndef #endif指令在编译时包含条件

#define TypeA
#define TypeB


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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM