用于在Visual Studio中使用整个项目或解决方案的参数定义预处理器宏的选项 [英] Options for defining preprocessor macros with parameters for entire project or solution in Visual Studio
问题描述
我希望某些具有参数的宏在项目中的所有文件中都可用,或者最好是一个完整的解决方案.在VS2010中,如果我使用类似
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中使用整个项目或解决方案的参数定义预处理器宏的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!