How to define macro at build step
-
here's my problem:
in my cpp file:
@#if defined(_MSC_VER)
#include .....
#else
#include something else
#endif@
to make my code portable. it's work fine when at visual studio. but i wanna switch to Qt from now, for uninstall 15Gb of visual studio .
i try go to project setting, add some argument to build steps:
@mingw32-make.exe -D _MSC_VER=1700@
but it's not work. anyone tell me how to define macro at build step? -
welcome to devnet
As it looks you are trying to set an MS macro for a MinGW compilation. I am not sure if there is something preventing this kind of setting. However, it is not wise to do so.
You can set "DEFINES in the .pro file for qmake":http://qt-project.org/doc/qt-5/qmake-variable-reference.html#defines
-
I never used cmake besides simply starting it. Therefore, I cannot help you. However, I would assume that it is as normally done.
Once again, you are trying to set a MS specific option for MinGW compiler. There is also a slight chance that MinGW is ignoring it, but I would expect at least a warning then.