SFML community forums

Help => Graphics => Topic started by: strongdrink on September 09, 2011, 09:51:30 pm

Title: error: ‘App’ does not name a type O_o
Post by: strongdrink on September 09, 2011, 09:51:30 pm
Hello, I'm running into this issue.. I'm not sure why its doing this.. but here is some of my code

main.h
Code: [Select]

#include <SFML/Graphics.hpp>
sf::RenderWindow App;


main.cpp
Code: [Select]

...
#include "main.h"
App.Create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0x20), "Kinect Particles");
...


thanks!
Title: error: ‘App’ does not name a type O_o
Post by: Groogy on September 09, 2011, 10:14:14 pm
Erhm.. do you do the include inside main? I believe that could result in some errors. Also why are you declaring the window in a header? That would mean you want it as a global variable?
Title: Re: error: ‘App’ does not name a type O_o
Post by: Haikarainen on September 09, 2011, 10:15:28 pm
Quote from: "strongdrink"
Hello, I'm running into this issue.. I'm not sure why its doing this.. but here is some of my code

thanks!


Dont think you can do that :S
Keep class declarations etc in .hpp files, and code in .cpp files!

For this simple thing just put both lines  in main.h into main.cpp, and delete include "main.h" in main.cpp
Title: error: ‘App’ does not name a type O_o
Post by: strongdrink on September 09, 2011, 10:15:49 pm
No, I'm not including in main
Yes, I need it in another file (a file with the class to render particles)
Title: error: ‘App’ does not name a type O_o
Post by: strongdrink on September 09, 2011, 10:16:59 pm
@Haikarainen: I need the declaration to be included in another file
Title: error: ‘App’ does not name a type O_o
Post by: Groogy on September 09, 2011, 10:19:49 pm
But does the App.Create call come directly after you include the .h file? Like it does in the example?

Also if you want to use it in another file then you use the keyword extern, otherwise the variable might be copied several times and then you define it normally in a .cpp file which will create the global variable.

Anyway doing it like this is so much hazzle that it is one of the key points WHY you don't have globals.
Title: error: ‘App’ does not name a type O_o
Post by: strongdrink on September 09, 2011, 10:20:06 pm
Ok I got it... App.Create needed to be inside main.. thanks! :P