Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

VS 2012 iostream syntax error!

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 lride   Members   

663
Like
0Likes
Like

Posted 06 November 2012 - 11:04 PM

I was writing some code and I decided to #include <iostream> in my new file.
But all of the sudden I get this error

c:\program files (x86)\microsoft visual studio 11.0\vc\include\iostream(12): error C2143: syntax error : missing ';' before 'namespace'

what happened?!?!?!? I never touched iostream header file
An invisible text.

#2 bradbobak   Members   

1803
Like
2Likes
Like

Posted 06 November 2012 - 11:08 PM

Maybe you forgot a ';' in the file you include right before iostream.

#3 lride   Members   

663
Like
0Likes
Like

Posted 06 November 2012 - 11:14 PM

Indeed I did. Such a weird error message it gave me.
An invisible text.

#4 rip-off   Moderators   

10897
Like
0Likes
Like

Posted 07 November 2012 - 06:45 AM

The thing to remember here is that the pre-processor handles the includes, and the compiler only sees the pre-processed source file (called a translation unit). Thus, from the compilers point of view you wrote something like this:
class SomeClass {
    // ...
} // <-- whoops

namespace std {
    class iostream {
        // ...
    }
}

// ...





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.