Is there a way in Visual C++ to #define something in a cpp file and have it defined in other cpp files as well?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
There are at least two options:
/D
compiler option to define the macro (this can also be set in the project properties under C/C++ -> Preprocessor -> Preprocessor Definitions)definitions.h:
class.h:
Someone has mentioned the pre-processor setting in project properties already.
But you can also select only a few of the .cpp that you want the definition in and then right click on those and go to properties, then: C/C++ -> Preprocessor -> Preprocessor Definitions
It will define the defines for those .cpp files only and not your whole project.
#define in a header (.h) file and #include that in all your .cpp files.