使用宏定义进行条件编译

    xiaoxiao2021-03-25  174

    main.cpp

    #include <iostream>

    using namespace std; int main() { #ifdef PRINT     cout << __LINE__ << endl; #endif     cout << __LINE__ << endl;     return 0;

    }

    终端命令行:g++ main.cpp  -D PRINT。

    通过实验发现,-D+宏定义,中间加不加空格,似乎都可以的。

    自己老是忘记,写个博客记录下来。

    转载请注明原文地址: https://ju.6miu.com/read-1781.html

    最新回复(0)