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

Author Topic: sf has not been declared  (Read 7755 times)

0 Members and 1 Guest are viewing this topic.

zys5945

  • Newbie
  • *
  • Posts: 16
    • View Profile
sf has not been declared
« on: March 11, 2015, 09:18:30 pm »
Hi I was having some trouble with using csfml, my comman to build is:

g++.exe -Wall -g -Wall -Iinclude -IC:\CSFML-2.2\include -c C:\test\src\test.cpp -o obj\Debug\src\test.o

and then the error messages pop up:

C:\test\src\test.cpp:2:17: error: 'sf' is not a namespace-name
 using namespace sf;
                 ^
C:\test\src\test.cpp:2:19: error: expected namespace-name before ';' token
 using namespace sf;
                   ^
C:\test\src\test.cpp: In function 'int main()':
C:\test\src\test.cpp:6:5: error: 'sf' has not been declared
     sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
     ^
C:\test\src\test.cpp:7:5: error: 'sf' has not been declared
     sf::CircleShape shape(100.f);
     ^
C:\test\src\test.cpp:8:5: error: 'shape' was not declared in this scope
     shape.setFillColor(sf::Color::Green);
     ^
C:\test\src\test.cpp:8:24: error: 'sf' has not been declared
     shape.setFillColor(sf::Color::Green);
                        ^
C:\test\src\test.cpp:10:12: error: 'window' was not declared in this scope
     while (window.isOpen())
            ^
C:\test\src\test.cpp:12:9: error: 'sf' has not been declared
         sf::Event event;
         ^
C:\test\src\test.cpp:13:33: error: 'event' was not declared in this scope
         while (window.pollEvent(event))
                                 ^
C:\test\src\test.cpp:15:31: error: 'sf' has not been declared
             if (event.type == sf::Event::Closed)


any idea?

zys5945

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: sf has not been declared
« Reply #1 on: March 11, 2015, 09:26:24 pm »
btw I simply copied and pasted the tutorial code from the tutorial page, pretty sure the scope is for c++ but how do I make it compatible with c?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: sf has not been declared
« Reply #2 on: March 11, 2015, 09:29:38 pm »
Indeed... the C++ example is not going to work in C. The API of CSFML is exactly the same as the C++ one, just in the C style. You should be able to figure out by yourself how to translate the examples, if you know how to program in C.
Laurent Gomila - SFML developer

zys5945

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: sf has not been declared
« Reply #3 on: March 11, 2015, 09:31:08 pm »
ty for the reply, but how do I translate?

zys5945

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: sf has not been declared
« Reply #4 on: March 11, 2015, 09:32:45 pm »
Oh nvm I got it, thx