【问题标题】:VSCode IntelliSense not recognising SDL_image extension library for SDL frameworkVSCode IntelliSense 无法识别 SDL 框架的 SDL_image 扩展库
【发布时间】:2020-02-13 07:57:37
【问题描述】:

我正在尝试在我的项目中将 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++ json visual-studio-code sdl


    【解决方案1】:

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

    #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>
    

    【讨论】:

      【解决方案2】:

      值得注意的是,我在 Windows 10 上工作时遇到了完全相反的问题,只是将它们更改为另一种方式。

      发件人:

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

      收件人:

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

      因为这是 .h 文件的确切路径

      【讨论】:

        猜你喜欢
        • 2021-10-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多