如何在 Visual Studio 中指定预处理器选项
How to specify preprocessor options in Visual Studio
在 Linux 和 g++ 上,我使用 -DPROGRAMNAME_VERSION=1.6
和 -DEIGEN_NO_DEBUG
来正确设置一些文本并分别提高执行速度。我正在 Windows 上进行一些测试,并且在使用 VS 2013 复制可执行文件时遇到问题。我搜索了 SO 并找到了 Properties->C/C++->Preprocessor->Preprocessor Definitions 的建议。这与此处 https://msdn.microsoft.com/en-us/library/hhzbb5c8.aspx 处的 Microsoft 文档一致。问题是当我尝试使用
/DEIGEN_NO_DEBUG
/DPROGRAMNAME_VERSION=1.6
日志文件显示1.00版本的默认值,执行时间是预期时间的两倍。
/DEIGEN_NO_DEBUG
用于 C++ Eigen 而另一个用作:
#ifndef PROGRAMNAME_VERSION
#define PROGRAMNAME_VERSION 1.00
#endif
两者都已经过测试并在 Linux 上工作。 SO 上的答案已被接受,这让我觉得我缺少一些小技巧来完成这项工作。
Praetorian 给出了正确答案。 Visual Studio 不使用 g++ 等使用的 /D 或 -D。它会为您插入。正确的用法如他的评论所示
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
在 Linux 和 g++ 上,我使用 -DPROGRAMNAME_VERSION=1.6
和 -DEIGEN_NO_DEBUG
来正确设置一些文本并分别提高执行速度。我正在 Windows 上进行一些测试,并且在使用 VS 2013 复制可执行文件时遇到问题。我搜索了 SO 并找到了 Properties->C/C++->Preprocessor->Preprocessor Definitions 的建议。这与此处 https://msdn.microsoft.com/en-us/library/hhzbb5c8.aspx 处的 Microsoft 文档一致。问题是当我尝试使用
/DEIGEN_NO_DEBUG
/DPROGRAMNAME_VERSION=1.6
日志文件显示1.00版本的默认值,执行时间是预期时间的两倍。
/DEIGEN_NO_DEBUG
用于 C++ Eigen 而另一个用作:
#ifndef PROGRAMNAME_VERSION
#define PROGRAMNAME_VERSION 1.00
#endif
两者都已经过测试并在 Linux 上工作。 SO 上的答案已被接受,这让我觉得我缺少一些小技巧来完成这项工作。
Praetorian 给出了正确答案。 Visual Studio 不使用 g++ 等使用的 /D 或 -D。它会为您插入。正确的用法如他的评论所示
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