当c_cpp_properties.json中 "defines": [ "_DEBUG","UNICODE","_UNICODE" ]
时在vscode 上写下如下代码:
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<windows.h>
#ifdef _DEBUG
#define _Test "ok"
#else
#define _Test "smg"
#endif
using namespace std;
int main(){
printf(_Test);puts("");
system("pause");
return 0;
}
在vsc中的终端输入指令,对于 g++ test.cpp -o test.exe,start test.exe 的运行结果是smg,但是对于 g++ -D _DEBUG test.cpp -o test.exe,start test.exe的运行结果是ok.
所以"defines": [ "_DEBUG","UNICODE","_UNICODE" ] 有什么用?