Options for defining preprocessor macros with parameters for entire project or solution in Visual Studio(在 Visual Studio 中使用参数为整个项目或解决方案定义预处理器宏的选项)
问题描述
我希望一些具有参数的宏在项目的所有文件中都可用,或者更好的是完整的解决方案.在VS2010中,如果我将它们添加到属性->配置属性->C/C++->预处理器中的预处理器定义中,使用类似的东西
I want some macros having parameters to be available in all files in a project or better a complete solution. In VS2010, if I add them to the Preprocessor Definitions in properties->Configuration Properties->C/C++->Preprocessor using something like
SQUARE(x)=((x)*(x));CUBE(x)=(SQUARE(x)*x);
编译器不使用宏定义.然而,这种方法可能很接近,因为当我将鼠标悬停在源代码中的宏上时,IntelliSense 提供了正确的定义.
the macro definitions are not used by the compiler. However the approach may be close since IntelliSense provides the correct definitions when I hover over the macros in the source code.
有没有一种方法可以定义宏并使它们可见,而无需在每个文件中包含带有其定义的标题?
Is there a way to define the macros and make them visible without including a header with their definitions in every file?
感谢您的任何想法!
推荐答案
将宏放在文件中,并使用/FI 选项自动将其包含到所有文件中:
Place the macro in a file and automatically include it into all files using the /FI option:
https://msdn.microsoft.com/en-us/library/8c5ztk84.aspx
语法:/FI[ ]路径名
Syntax: /FI[ ]pathname
/FI 选项与将文件包含在每个源文件的顶部具有相同的效果.
The /FI option has the same effect as including the file at top of every source file.
这篇关于在 Visual Studio 中使用参数为整个项目或解决方案定义预处理器宏的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Visual Studio 中使用参数为整个项目或解决方案定义预处理器宏的选项


- 如何对自定义类的向量使用std::find()? 2022-11-07
- Stroustrup 的 Simple_window.h 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 近似搜索的工作原理 2021-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- C++ 协变模板 2021-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 从python回调到c++的选项 2022-11-16
- STL 中有 dereference_iterator 吗? 2022-01-01