pandaman1234
pandaman1234

Reputation: 523

Is there a macro that can be used in a C++ project in Visual Studio to identify the current SOLUTION configuration?

I have a VS2008 solution in which there is a C++ project (we'll name it Project1 for clarity's sake). The project's purpose is to test the executable generated by the compilation of another C++ project (Project2) in the same solution. The executable being tested (Project2.exe) is built in the same folder than the executable generated by our Project1 (Project1.exe). Here's what is looks like in the build folder:

Build_path/Debug

Build_path/Release

The project Project1 is set in the Configuration Manager to always build in debug (even when the solution build in release), since there is a problem with one of the third party tool used in Project1 when we compile in release. So any preprocessor definitions that would identify Project1's configuration would always be set to debug. Knowing this and the fact that Project2 build in release when the Solution Configuration is set to build in release, how can project1 locate project2 when building the solution in release, since it always search in the same folder it is located in?

Constraint(s):

I am using GetModuleFileName to fetch Project1's executable and from that location (which is always in the debug folder), the only solution I found was to search for a macro representing the current solution configuration, which would help me to fetch Project2.exe in the release folder when building my solution in release (but Project1 still in debug) by adding ../Release in my path and stay in the debug folder when Project2 is actually in the debug folder (when the solution is built in debug) by adding ../Debug in my path.

A little pseudo-code would look like this:

If SOLUTION_CONFIGURATION == DEBUG // Project 1 and Project2 is in debug folder 
  add ../Debug in my research path to locate Project2_Debug.exe from Project1_Debug.exe's location
Else if SOLUTION_CONFIGURATION == RELEASE // Project1 is in debug and Project2 is in release folder
  add ../Release in my research path to locate Project2.exe from Project1_Debug.exe's location
End if

Upvotes: 2

Views: 1733

Answers (1)

Thomas Matthews
Thomas Matthews

Reputation: 57698

There are no standardard macros for representing configurations and version information.

However, MS maintains a list of predefined macros for Visual Studio.

Some may be available with other compilers.

P.S. I found the site by searching the internet using the keywords "Visual Studio predefined macros".

Upvotes: 1

Related Questions