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

Author Topic: namespace errors  (Read 4390 times)

0 Members and 1 Guest are viewing this topic.

bobbaluba

  • Newbie
  • *
  • Posts: 2
    • View Profile
namespace errors
« on: October 20, 2009, 05:21:01 pm »
I'm trying to run this piece of code:
Code: [Select]
#include <SFML/System.hpp>
#include <iostream>

#include "stdafx.h"

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        std::cout << Clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);
    }

    return 0;
}

I get this error:
1>e:\development\sfmltest\sfmltest\sfmltest.cpp(8) : error C2653: 'sf' : is not a class or namespace name

Why is that?

bobbaluba

  • Newbie
  • *
  • Posts: 2
    • View Profile
namespace errors
« Reply #1 on: October 20, 2009, 05:57:23 pm »
unchecking "use precompiled headers" when creating a project solved the problem?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
namespace errors
« Reply #2 on: October 20, 2009, 08:48:38 pm »
Yes. If you use precompiled headers with MSVC++, all the code before
Code: [Select]
#include "stdafx.h" is ignored. That's why your identifiers aren't found, the same would apply to std::cout.

A lot of information concerning precompiled headers (or Microsoft Visual C++ in general) can be found on MSDN, by the way.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Samuel

  • Newbie
  • *
  • Posts: 1
    • View Profile
namespace errors
« Reply #3 on: December 15, 2009, 11:47:31 am »
Thanks Nexus. I have problem like this and your solution helped me.

____________________
play online casino