gpt4 book ai didi

c++ - 什么是正确的 macOS vscode intellisense C++ 包含标准库的路径?

转载 作者:太空狗 更新时间:2023-10-29 21:13:05 27 4
gpt4 key购买 nike

我在 macOS Sierra 上使用 Visual Studio Code 1.14.2 并安装了 Microsoft C/C++ ms-vscode.cpptools扩展,但在设置包含路径时遇到问题,无法让 IntelliSense 正确检查标准库 header ,而不会产生错误并回退到“标记解析器”机制。

默认c_cpp_properties.json包含此 vscode 版本的以下内容:

{
"configurations": [
{
"name": "Mac",
"includePath": [
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
"/usr/local/include",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/include",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
"/usr/include",
"${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
"/usr/local/include",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/include",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
"/usr/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
},
...
}

例如,使用一个简单的 C++ 文件,例如:

#include <exception>

int main() {
return 0;
}

#include <exception>有下划线。将鼠标悬停在它上面:

file: 'file:///path/to/vscode.cc' severity: 'Info' message: '#include errors detected. Please update your includePath. IntelliSense features for this translation unit (/path/to/vscode.cc) will be provided by the Tag Parser.' at: '1,1' source: ''

file: 'file:///path/to/vscode.cc' severity: 'Info' message: 'cannot open source file "endian.h" (dependency of "exception")' at: '1,1' source: ''

我在我的文件系统中搜索了 endian.h .剔除看起来与主机开发实际相关的可能性(即放弃 iOS/WatchOS/等):

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/i386/endian.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/machine/endian.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/i386/endian.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/endian.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/i386/endian.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/machine/endian.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/i386/endian.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/machine/endian.h
/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/i386/endian.h
/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/machine/endian.h
/usr/include/i386/endian.h
/usr/include/machine/endian.h

有谁知道这个问题的正确解决方法是什么?

最佳答案

这原来是 IntelliSense 引擎中的一个配置错误。 Mac header 需要定义符号 __LITTLE_ENDIAN__,但事实并非如此。我们已经在最新的扩展更新中纠正了这个问题,因此不再需要添加到 endian.h 的路径。

关于c++ - 什么是正确的 macOS vscode intellisense C++ 包含标准库的路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45520903/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com