我试图在我的项目中将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/