Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Incomplete Type (sf::Event) when including SFML/Graphics/Texture  (Read 3174 times)

0 Members and 1 Guest are viewing this topic.

tschaei

  • Newbie
  • *
  • Posts: 5
    • View Profile
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?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Incomplete Type (sf::Event) when including SFML/Graphics/Texture
« Reply #1 on: May 20, 2012, 07:46:55 pm »
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?
« Last Edit: May 20, 2012, 07:48:35 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

tschaei

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Incomplete Type (sf::Event) when including SFML/Graphics/Texture
« Reply #2 on: May 20, 2012, 08:33:59 pm »
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.