c++ - VSCode IntelliSense无法识别SDL框架的SDL_image扩展库

标签 c++ json visual-studio-code sdl

我试图在我的项目中将SDL_image扩展库包含到SDL.framework中,但是VScode的IntelliSense始终用错误行强调我的#include<SDL_image.h>。它产生以下错误:

cannot open source file "SDL2/SDL.h" (dependency of "SDL_image.h")

我能够成功编辑c_cpp_properties.json includePath,因此IntelliSense可以识别SDL框架,但是当尝试对SLD_image执行相同操作时,它失败了。

这是我的c_cpp_properties.json文件:
{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/Library/Frameworks/SDL2_image.framework/Headers",
                "/Library/Frameworks/SDL2.framework/Headers",
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "macFrameworkPath": [
                "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

最佳答案

问题不是c_cpp_properties.json,而是SDL_image.h文件。如果您使用的是VScode(尽管是在Mac上),并且在使用IntelliSense时遇到相同的问题,请从SDL_image.h中更改以下include语句:

#include <SDL2/SDL.h>
#include <SDL2/SDL_version.h>
#include <SDL2/begin_code.h>
#include <SDL2/close_code.h>

对此:
#include <SDL.h>
#include <SDL_version.h>
#include <begin_code.h>
#include <close_code.h>

关于c++ - VSCode IntelliSense无法识别SDL框架的SDL_image扩展库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60202947/

相关文章:

c++ - 使用命令行将二维数组传递给 C++

c# - 在 C# 中从串口接收数据有问题吗?

json - 如何解决 Azure WebJob SDK 中的依赖关系冲突?

visual-studio-code - 如何卸载 Python 语言服务器(由 VS Intellicode 扩展安装)

c++ - MinGW-w64 g++ 是否公开了 Microsoft ucrt 对 C11 `getenv_s` 函数的实现?如果是,要包含什么标题?

C++11 线程不适用于虚拟成员函数

python - 使用 Python 提取列表中的字典键

javascript - jQuery:仅显示新的 JSON 数据,使用自己的段落标记进行迭代

visual-studio-code - 如何在 VS Code 中的当前选择上运行外部命令?

java - 如何在 VS Code 中启用 Java 语法高亮