Jim Monte
Jim Monte

Reputation: 121

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

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!

Upvotes: 4

Views: 1701

Answers (1)

Matthias
Matthias

Reputation: 1352

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.

Upvotes: 2

Related Questions