How to specify preprocessor options in Visual Studio

764 views Asked by At

On Linux with g++ I use -DPROGRAMNAME_VERSION=1.6 and -DEIGEN_NO_DEBUG to properly set some text and increase the speed of execution respectively. I am doing some testing on Windows and am having trouble duplicating the executable with VS 2013. I searched around SO and found suggestions for Properties->C/C++->Preprocessor->Preprocessor Definitions. This agrees with Microsoft's documentation found here https://msdn.microsoft.com/en-us/library/hhzbb5c8.aspx. The problem is that when I try to do it with

/DEIGEN_NO_DEBUG
/DPROGRAMNAME_VERSION=1.6

The log file shows the default value of version 1.00 and the execution time is twice that of the expected time. The /DEIGEN_NO_DEBUG is used for C++ Eigen while the other is used as such:

#ifndef PROGRAMNAME_VERSION
#define PROGRAMNAME_VERSION 1.00
#endif

Both have been tested and work on Linux. The answers on SO have been accepted which makes me think there is some small trick I am missing to make this work.

1

There are 1 answers

0
Matt On BEST ANSWER

Praetorian gave the correct answer. Visual Studio doesn't use the same /D or -D that g++, etc use. It inserts that for you. The correct usage is as shown in his comment.

I'm guessing you put /DPROGRAMNAME_VERSION=1.6 into the settings instead of PROGRAMNAME_VERSION=1.6. MS build will insert the /D for you when invoking the compiler. – Praetorian