Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using #define one time for multiple source files

Is there a way in Visual C++ to #define something in a cpp file and have it defined in other cpp files as well?

like image 313
Luminous_Path Avatar asked Dec 01 '22 10:12

Luminous_Path


1 Answers

There are at least two options:

  • Put the definition into a header file and include that header file in all the source files in which you need the definition
  • Use the /D compiler option to define the macro (this can also be set in the project properties under C/C++ -> Preprocessor -> Preprocessor Definitions)
like image 191
James McNellis Avatar answered Dec 25 '22 06:12

James McNellis