compiling with c++ standard library

this might be out of the scope of this tutorial but I tried to compile the code with <iostream> included, without success. any suggestions?

here is the error log:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xlocale(337) : error C2220: warning treated as error - no 'object' file generated
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xlocale(337) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(64) : error C2159: more than one storage class specified
        c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(117) : see reference to class template instantiation 'std::_Iosb<_Dummy>' being compiled
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(64) : error C2059: syntax error : '='
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(64) : error C2238: unexpected token(s) preceding ';'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(136) : error C2589: 'static' : illegal token on right side of '::'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(136) : error C2988: unrecognizable template declaration/definition
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(136) : error C2059: syntax error : '::'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(138) : error C2065: '_Dummy' : undeclared identifier
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(138) : error C2923: 'std::_Iosb' : '_Dummy' is not a valid template type argument for parameter '_Dummy'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\ios(249) : error C2059: syntax error : 'type'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\ios(250) : error C2143: syntax error : missing ';' before '{'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\ios(250) : error C2447: '{' : missing function header (old-style formal list?)
[Finished in 0.4s]

Edited by Erlend on
Have you tried doing what error message is asking? To add /EHsc command-line argument for compiler.
Sorry i tried to add that as well, here is the output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
win32_handmade.cpp
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(64) : error C2159: more than one storage class specified
        c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(117) : see reference to class template instantiation 'std::_Iosb<_Dummy>' being compiled
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(64) : error C2059: syntax error : '='
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(64) : error C2238: unexpected token(s) preceding ';'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(136) : error C2589: 'static' : illegal token on right side of '::'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(136) : error C2988: unrecognizable template declaration/definition
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(136) : error C2059: syntax error : '::'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(138) : error C2065: '_Dummy' : undeclared identifier
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xiosbase(138) : error C2923: 'std::_Iosb' : '_Dummy' is not a valid template type argument for parameter '_Dummy'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\ios(249) : error C2059: syntax error : 'type'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\ios(250) : error C2143: syntax error : missing ';' before '{'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\ios(250) : error C2447: '{' : missing function header (old-style formal list?)
[Finished in 0.6s]

Edited by Erlend on
Sanity check: if you remove the include directive for iostream, does it compile fine?
Oh, now errors happens on 64 line of xiosbase header. If you open it you'll see following:
1
	static const _Fmtflags internal = (_Fmtflags)_IOSinternal;


See that "internal" identifier? Casey does (imho) some pretty bad stuff with #define's here. He changes meaning of "internal" identifier to mean something else for compiler. And that's when everything breaks. Everything will also break if somebody will name variable as "global_variable" or "local_persist".

Workaround would be to put "#include <iostream>" before "#define internal static" in win32_handmade.cpp file. Then it should compile. Just put "#include <iostream>" Before anything else in win32_handmade.cpp (put it in line 1).

Edited by Mārtiņš Možeiko on
That did it - thank you mmozeiko!

btw love the new c++11 features like lambdas, function, unique_ptr and auto which are supported on vs2013.

Edited by Erlend on