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

Author Topic: unknown type 'namespace'  (Read 10996 times)

0 Members and 2 Guests are viewing this topic.

smexhy

  • Newbie
  • *
  • Posts: 6
    • View Profile
unknown type 'namespace'
« on: August 06, 2013, 10:22:13 pm »
Hello, i followed the tutorial on how to set up SFML with GCC (code::blocks) and i made a game with it so far, but now everytime I make another program and have to use SFML i have to re-do the whole tutorial which is really taking a lot of time.
So i went to Settings > Compiler > Global Compiler Settings and did the tutorial putting the lib's in Global Compiler Settings than in Build Options and now when I compile any program it gets me this error:

..\..\..\..\..\SFML\SFML-2.1\include\SFML\Config.hpp|129|error: unknown type name 'namespace'|
..\..\..\..\..\SFML\SFML-2.1\include\SFML\Config.hpp|130|error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|
..\..\..\..\..\SFML\SFML-2.1\include\SFML\System\Time.hpp|34|error: unknown type name 'namespace'|
..\..\..\..\..\SFML\SFML-2.1\include\SFML\System\Time.hpp|35|error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|
..\..\..\..\..\SFML\SFML-2.1\include\SFML\System\Clock.hpp|35|error: unknown type name 'namespace'|
..\..\..\..\..\SFML\SFML-2.1\include\SFML\System\Clock.hpp|36|error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|
..\..\..\..\..\SFML\SFML-2.1\include\SFML\System\Err.hpp|32|fatal error: ostream: No such file or directory|
||=== Build finished: 7 errors, 0 warnings (0 minutes, 0 seconds) ===|

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: unknown type 'namespace'
« Reply #1 on: August 06, 2013, 11:39:49 pm »
It looks like you're trying to compile C++ code with a C compiler. You messed up your compiler settings, if it was working before your changes.
Interested in using SFML with Python ? Try out its Python binding!

smexhy

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: unknown type 'namespace'
« Reply #2 on: August 07, 2013, 01:16:31 pm »
How do i set code::blocks with SFML correctly, may i ask?
The tutorial for 2.1 and 2.0 show only how to set it locally, to a project :(.
Thank you!

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: unknown type 'namespace'
« Reply #3 on: August 07, 2013, 01:40:15 pm »
1) Go to Settings > Compiler > Global Compiler Settings.
2) Select your compiler
3) Press "reset defaults"
4) Tab "Search directories" > Compiler : add the location of the SFML headers
5) Tab "Search directories" > Linker: add the location of the SFML libraries (.lib/.so)
6) Tab "Linker settings" > Link libraries: add "sfml-system", etc.
7) Press ok and you're done.
Interested in using SFML with Python ? Try out its Python binding!

smexhy

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: unknown type 'namespace'
« Reply #4 on: August 07, 2013, 02:11:17 pm »
Thanks, but still doesn't work. Did exactly what u said.
Same error.
I have Code::Blocks 12.11 and i think i have the compiler which comes with it.
« Last Edit: August 07, 2013, 02:19:13 pm by smexhy »

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: unknown type 'namespace'
« Reply #5 on: August 07, 2013, 02:39:50 pm »
I did exactly how I said and it worked :p

In your "Toolchains executable" tab, what C++ compiler is set ?
Interested in using SFML with Python ? Try out its Python binding!

smexhy

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: unknown type 'namespace'
« Reply #6 on: August 07, 2013, 02:45:47 pm »
Here it is.

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: unknown type 'namespace'
« Reply #7 on: August 07, 2013, 02:58:40 pm »
I'm not on Windows, but just like that, shouldn't the compiler be named "MinGW compiler" or something ? Is your project correctly set up to use the right compiler ? Are you sure there aren't options in your project which overrides the compiler options ? Be careful, there are global options and configuration-specific options (Release, Debug), so make sure your project is built using the configuration you want.
Interested in using SFML with Python ? Try out its Python binding!

smexhy

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: unknown type 'namespace'
« Reply #8 on: August 07, 2013, 03:29:51 pm »
Did everything as it was on my working project.
Now i can't make any more sfml program, the only that works is the first one i made...  >:(

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: unknown type 'namespace'
« Reply #9 on: August 07, 2013, 03:34:47 pm »
Don't give up, it's all about setting up your compiler. At worst, try a fresh install. ;)

Another hint, there's an option to display the full command line Code::blocks has used to build your project.(Other settings > Compiler logging : chose Full command line). You can still copy/paste this command line here to see how broken CodeBlocks is :p
Interested in using SFML with Python ? Try out its Python binding!

smexhy

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: unknown type 'namespace'
« Reply #10 on: August 07, 2013, 04:35:56 pm »
It's already on Full command line... I've no ideea how to fix it. I reinstalled code::blocks but it still has the old settings :\... A fresh install to what?

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: unknown type 'namespace'
« Reply #11 on: August 07, 2013, 06:42:17 pm »
That's why you need to manually remove the C::B config files...

And the goal of having the full command lines displayed is to see what's wrong with your settings. So unless you copy/paste them here, we can't help you.
Interested in using SFML with Python ? Try out its Python binding!

Wulframm

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: unknown type 'namespace'
« Reply #12 on: June 27, 2014, 01:27:58 am »
I know this hasn't been active for a while but since this problem was really getting to me and i  found the solution i thought i'd just leave it here.

I had the same issue, same errors, thought it was the compiler but it wasn't, i had in fact accidentally saved my file as .c instead of .cpp.

 

anything