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



我正试图将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>

值得注意的是,我在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文件的确切路径

最新更新