So, I am learning SDL 2 and using it with vscode, this is my file structure
in the miain.cpp file this is my code:
#include <game.h>
int main(int argc, char* argv[]){
int screenWidth = 1024;
int screenHight = 600;
Game game("Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screenWidth, screenHight, SDL_WINDOW_SHOWN);
while(game.gameState != GameState::EXIT){
SDL_Event evnt;
SDL_PollEvent(&evnt);
switch (evnt.type){
case SDL_QUIT:
game.gameState = GameState::EXIT;
break;
default:
break;
}
};
return 0;
}
when I compile I get this error:
fatal error: game.h: No such file or directory
>Solution :
The problem is not VSCode but the project folding structure. You are trying to import a file using a wrong path. The correct one is #include <../headers/game.h>
.
I suggest you to move main.cpp
in the root project directory and game.h
file path will be #include <include/headers/game.h>
.