SFML community forums
Help => Window => Topic started by: tschaei on May 20, 2012, 07:38:02 pm
-
My project setup is as follows:
A game.cpp which contains the game loop etc. It includes "Player.h", my player class, "Bullet.h" and <SFML/Graphics.hpp>. The Player.h file includes <SFML/Graphics/Sprite.hpp>, so does the "Bullet.h" (ifndef protection is in place). Now if I include <SFML/Graphics/Texture.hpp> in my "Bullet.h" Visual Studio suddenly marks my Usage of sf::Event in my gameloop as erroneous, stating that "An incomplete type is not allowed". When I don't include <SFML/Graphics/Texture.hpp>, I don't get this error and the program compiles just fine (if I don't use sf::Texture in my Bullet class obviously). What's wrong here?
-
Generally, you should always include the headers you need (here the one for sf::Event) and not rely on other headers to include them automatically.
But does the code really compile when you omit the #include directive?
-
Generally, you should always include the headers you need (here the one for sf::Event) and not rely on other headers to include them automatically.
Did that now. The source of my problem was a missing semicolon after my bullet class. For some reason Visual Studio did not show the error anymore when I removed the Texture.hpp include but the program didn't actually compile like that.