Important: Please read the Qt Code of Conduct -

How to define macro at build step

  • here's my problem:
    in my cpp file:
    @#if defined(_MSC_VER)
    #include .....
    #include something else
    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":

  • hi koahnig, my project is cmake project, i try open CMakeLists.txt in Qt Creator, then Qt generate a folder with .cbp(Code blocks project) file. My project loaded, but it has no .pro file for me to config. how should i do now?

  • 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.

Log in to reply