Can you make VC ++ Solution a #defines preprocessor for loaded projects?

I have a library that supports #define to control how it was created. However, the library can be used by several EXE projects that want to have different versions. Can I make the app / EXE project install #define, which the library will use when building, or install it in the solution?

The only other option I can think of is to create a separate build configuration in the library project, but it will quickly get out of hand. This is common, for example, unicode / non-unicode, but then you must multiply the number of configurations for each combination.

+5
source share
2 answers

The following approach assumes that each .EXE / application (which uses this library) has its own Visual Studio solution.

You have control over the library, right? Steps 1-3 will make changes to the project file, and step 4 adds the file to the library source code.

  • Set project properties> C / C ++> Advanced> Strength Turns On mylibrary_solution_defines.h.

  • Change project properties> C / C ++> General> Additional inclusion directories to be placed $(SolutionDir);at the beginning of the directory list.

  • a > > - . , $(SolutionDir)$(ProjectName)\$(Configuration)? , ; .lib .obj.

  • , mylibrary_solution_defines.h , #include "mylibrary_solution_defines.h" .

  • /EXE- - , , - mylibrary_solution_defines.h #defines .

, ? #include "mylibrary_solution_defines.h", . , . , ConsoleModeInterfaceProgram.sln , #define TEXTONLY 1, mylibrary_solution_defines.h, , ConsoleModeInterfaceProgram.sln.

+5

, . , .

- "" - , .

0

All Articles