简体   繁体   中英

How to specify preprocessor options in Visual Studio

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM