I just opened someone else\'s Visual Studio project and in their build properties they have a few custom path macro\'s they are using for their include and lib directories.
Here the approach is described with pictures: https://sites.google.com/site/pinyotae/Home/visual-studio-visual-c/create-user-defined-environment-variables-macros
In Visual Studio you need to:
Here is a tutorial on Project Property Sheets: http://www.dorodnic.com/blog/2014/03/20/visual-studio-macros/
Re: hmm.. I dont seem to have the "User Macros" option under "Common Properties". I am using VS 2010 Pro
The User Macros option doesn't show up if you open the property dialog for a proj file, as you do in the normal Files view. You have to switch to the Propery view, expand some project, and choose a Property Page (*.props) that you added for the purpose. The User Macros show up there.
Or, you can just edit the XML directly. Macros work just fine if defined in a .*proj file, but making it a "User Macro" is pointless if there's no edit page. So just make it a plain property in a <PropertyGroup>.
As pointed out earlier, it also pulls in Environment Variables. However, you have to be sure to set them in a context where the Devenv will see them! Do that in a command shell and then run DEVENV from that same command prompt. When I had that situation, I made a batch file to set the proper variables and launch DEVENV, and put that bat file icon on the desktop.
Try the other way without the hassle adding to each Property Sheet
Go to Windows OS System Properties > Environment Variables, just New and input the Variable e.g.: MY_PATH and value e.g.: D:\Dev_Path\
after that you have to restart your Visual Studio, you should be able to have ${MY_PATH} in macro list
p/s: just notice Jason Williams answered above is the OS Environment Variables method
Same answer as to @Serge Rogatch, except that I was not able to find "Property Manager" in View.
Visual steps for quick navigation:
The way for the latest visual studio versions (2015+) Is as follows:
To create a user-defined macro:
Source
You can just define them as os environment variables, which is probably what the original author did.