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 中使用参数为整个项目或解决方案定义预处理器宏的选项
基础教程推荐
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- CString 到 char* 2021-01-01
