C/C++ IntelliSense
Settings
-> Extensions
-> C/C++
-> IntelliSense
-> C_CPP>Default:Defines
按照以上步骤在对应位置填写需要的宏参数,可以使用=
给参数赋值。作用与 vscode 的解析环境,可以控制非活动区变暗。
c_cpp_propeties.json
ctrl+shift+p
-> C/C++: Edit Configurations (JSON)
按照步骤打开配置文件,在 defines
属性里填写宏参数。作用与 vscode 的解析环境,可以控制非活动区变暗。
cStandard
属性可以控制 vscode 模拟对应的 C 环境。
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"DEBUG"
],
"complierPath": "usr/bin/gcc",
"cStandard": "gnu99",
"cppStandard": "c++17",
"intelliSenseMode": "Linux-gcc-x64"
}
],
"version": "4"
}
task.json
ctrl+shift+p
-> Tasks: Configure Task
按照步骤打开配置文件,在 args
属性里填写宏参数。作用相当于 gcc 编译时的 CFLAGS。
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe 生成活动文件",
"command": "D:/Program Files (x86)/mingw64/bin/gcc.exe",
"args": [
"-g",
"-DDEBUG"
],
"options": {
"cwd": "${workspaceRoot}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Default build task"
}
],
"version": "2.0.0"
}