c++ - How can I use different #defines for one project used by two different solutions without creating new configurations
问题描述
This is for Visual Studio 2015, C++
I have one project that is compiled as a library and has some #if - #else
statements
#ifdef DXTK
//...
#elif defined DXUT
//...
#else
//...
#endif
I have two different solutions (with a separate executable project each) that both include this library as a project.
I need to #define DXUT
in one executable project and #define DXTK
in the other
But the problem is, my definitions in pre-processor for the executable projects (not the library) do not affect the library project's #if - #else
statements
I know one recommendation is to create different configurations for the library project and use one in one solution, and another in the other.
But is there a way to pass the preprocessor definition in the entire solution?
I tried adding /DDXUT
to C/C++ -> Command Line
for the executable projects, but it did not work.
How can I do this without creating a new configuration for each project?
解决方案
Possible duplicate of this: Are Preprocessor Definitions compiled into a library?
Short answer is No, you cannot do what you want to do without different configurations, as the code that is compiled into that library has been transformed before you even include the library into a different project.
推荐阅读
- bash - (rm/xargs) 故意减慢每秒传递给命令的参数数量?
- javascript - 如何在函数返回之前从 AJAX 调用中获取结果?
- wordpress - WoCoommerce:在自定义循环中获取捆绑数据项产品
- websocket - 将数据从事件流式传输到 Suave 套接字
- ios - 错误响应状态代码不可接受:405
- python - 如何检查警告过滤器?
- javascript - 如何使用 mongoose 从 mongodb 创建嵌套层次结构数据
- python - MatPlotLib 将饼图添加到表的末尾
- javascript - Alertify 和 bootstrap 4 模式之间的 tabindex 冲突
- snowflake-cloud-data-platform - 使用 DBeaver 未从雪花返回数据