Visual Studio 2010 & 2008 can’t handle source files with identical names in different folders?

So @Hans Passant pointed in the right direction, Thanks!! You don’t have to list the file, a folder is sufficient. Then if you look in the defined macros at the bottom of the VS 2010 list, you’ll see:

%(RelativeDir)/ Univariate/

The problem, as posted, was actually a simplified version of what I’m working on — a couple of levels of folders in a single project and there are a couple of name conflicts. Hence, I really wanted someway to just “fix” it…

If you right click on the project in the solution explorer, choose C/C++ -> “Output Files” and type the following into the “Object File Name” box:

$(IntDir)/%(RelativeDir)/

Note that I also selected (All Configurations, All Platforms) from the drop downs. This will compile every file in a directory hierarchy which mirrors the source tree. VS2010 will begin the build by creating these directories if they don’t exist. Further, for those who hate white space in their directory names, this macro does remove all spaces, so there is no need to play around with double quotes when using it.

This is exactly what I wanted — identical to the way my Makefiles work on the Ubuntu side, while still keeping the source tree clean.

Leave a Comment