我对使用 VSCode 的 C/C++ 扩展还很陌生。我很困惑 .vscode/c_cpp_properties.json
中定义的配置之间的确切角色和关系是什么。文件和 C_Cpp.xxx
settings.json
中允许的设置系列文件。
这两种机制是否允许在不同的优先规则或其他规则下配置相同的设置?
最佳答案
因此显然存在优先关系:C_Cpp.xxx
系列设置用作全局默认值,可以用作用户级别默认值(~/Library/Application Support/Code/User/settings.json
)或文件夹级别默认值(如果已配置)。
此文档中介绍了这种关系:(Customizing default settings)
You can override the default values for properties set in c_cpp_properties.json
如果写成这样可能会更好理解:
You can override the default values for properties defined in
settings.json
with those set inc_cpp_properties.json
.
这里的理解是两个上下文之间存在名称对应和匹配。文档中的语言似乎用术语“VS Code 设置”来表示 settings.json
中的内容。
当您实际设法通过调用以下命令之一在工作区中创建 c_cpp_properties.json
时,这更有意义:
通过 JSON 编辑时的默认配置在我的 Mac 上呈现为...
{
"configurations": [
{
"name": "Mac",
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
此处列出了所有逐项 Cpp 配置,仅供引用 (c_cpp_properties.json reference) ,映射如下:
// settings.json
{
C_cpp.default.<configName> : <configValue>
}
==>
// c_cpp_properties.json
{
"configurations": [
{
"name": "MyLocalConfig",
<configName>:<configValue>,
}
}
关于c++ - Visual Studio Code : settings. json 系列的 C_Cpp.xxx 配置与 c_cpp_properties.json?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58312341/