2

Hopefully this isn't a duplicate. I tried to search for an answer to my question, but the word 'macro' just has too many different applications to filter the search results very effectively.

Anyway, I recently noticed in another Visual C++ (VS2010) project that custom macros were used to set up VC++ directories (include, lib) or link libraries. Something like this: "libjpeg-$(JPEG_LIB_VERSION)-static.lib", etc.

How does one go about doing that? I can't remember in what project I saw that technique, so I haven't been able to find it again to investigate, but this would be very useful when building against local builds or particular versions of widely-distributed software (say, Boost, for instance).

There's this (Visual C++ Express and setting env variables solution wide), which I suppose kinda-sorta answers the question, but not really.

Community
  • 1
  • 1
Ben Collins
  • 20,538
  • 18
  • 127
  • 187

1 Answers1

2

The macro being used may be an environment variable, or it may indeed be a custom macro.

If it is an environment variable, you could follow the documentation as mentioned in this MSDN document How to: Use Environment Variables in a Build

However, if it is not an environment variable and you want to create your own, there is another MSDN document for that How to: Add New Property Sheets to C++ Projects

For additional references on creating a custom macro, please see How to add environmental variable to VS solution (.sln )

For additional references on using an environment, please see Macros/Environment variable in .sln and .vcproj files for Visual studio

Community
  • 1
  • 1
josephthomas
  • 3,256
  • 15
  • 20
  • Thanks for all the references. I figure you're probably right to point out that environment variables can be used in a build. – Ben Collins Mar 27 '12 at 19:38