我对使用VSCode的C / C ++扩展还很陌生。我很困惑.vscode/c_cpp_properties.json
文件中定义的配置与C_Cpp.xxx
文件中允许的settings.json
系列设置之间的确切角色和关系。
这两种机制是否允许在不同的优先规则或其他条件下配置相同的设置?
答案 0 :(得分:1)
因此,显然存在优先级关系:C_Cpp.xxx
系列设置用作全局默认值,可以用作用户级默认值(~/Library/Application Support/Code/User/settings.json
)或文件夹级默认值(如果已配置)。
本文档介绍了这种关系:(Customizing default settings)
您可以覆盖c_cpp_properties.json中设置的属性的默认值
如果写为:
您可以用
settings.json
中设置的属性覆盖c_cpp_properties.json
中定义的属性的默认值。
这里的理解是,两个上下文之间存在名称对应和匹配。文档中的语言似乎用{em>“ VS代码设置” 来表示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
}
在这里(c_cpp_properties.json reference)列出所有详细的Cpp配置,以供参考,映射如下:
// settings.json
{
C_cpp.default.<configName> : <configValue>
}
==>
// c_cpp_properties.json
{
"configurations": [
{
"name": "MyLocalConfig",
<configName>:<configValue>,
}
}