Options for defining preprocessor macros with parameters for entire project or solution in Visual Studio

Deadly 提交于 2021-02-04 18:30:08

问题


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); 

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?

Thanks for any ideas!


回答1:


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

Syntax: /FI[ ]pathname

The /FI option has the same effect as including the file at top of every source file.



来源:https://stackoverflow.com/questions/43242003/options-for-defining-preprocessor-macros-with-parameters-for-entire-project-or-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!