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

Author Topic: error: ‘App’ does not name a type O_o  (Read 3823 times)

0 Members and 1 Guest are viewing this topic.

strongdrink

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
error: ‘App’ does not name a type O_o
« 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!

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
error: ‘App’ does not name a type O_o
« Reply #1 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?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Haikarainen

  • Guest
Re: error: ‘App’ does not name a type O_o
« Reply #2 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

strongdrink

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
error: ‘App’ does not name a type O_o
« Reply #3 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)

strongdrink

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
error: ‘App’ does not name a type O_o
« Reply #4 on: September 09, 2011, 10:16:59 pm »
@Haikarainen: I need the declaration to be included in another file

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
error: ‘App’ does not name a type O_o
« Reply #5 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.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

strongdrink

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
error: ‘App’ does not name a type O_o
« Reply #6 on: September 09, 2011, 10:20:06 pm »
Ok I got it... App.Create needed to be inside main.. thanks! :P

 

anything