Handmade Hero»Forums»Code
Tim
13 posts
Compiling - errors from previous local declaration
Hello All,

I got everything set up and working with day 017, but now fast forward a bit and the compilation is no longer matching with what is on the stream.
I tried days 151 and 100, and both fail for the same reasons:

(shortened for brevity)
1
2
3
4
intrinsics.h(34): C4244: 'initializing': conversion from 'double' to 'real32'
render_group.cpp(294): C4456: declaration of 'X' hides previous local declaration
handmade.cpp(1197): C4456: declaration of 'RelP' hides previous local declaration
win32_handmade.cpp(1623): C4456: decl. of 'PlayCursor' hides previous local decl.

etc.

Does anyone have any suggestions as to why it doesn't compile on my machine?
I am compiling with sublime text as my editor, I call
1
2
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
set path=w:\handmade\misc;%path%

at the top of my build.bat, have VS community 2015, am running Windows 10, and otherwise just copied over the contents of the zip files.

Thank you!
Mārtiņš Možeiko
2559 posts / 2 projects
Compiling - errors from previous local declaration
Edited by Mārtiņš Možeiko on
Casey is using Visual Studio 2013. VS2015 compiler changed a bit and is finding more warnings and we are compiling with warnings treated as errors.

So you need to do one of these things:
a) adjust source to not produce warnings
b) remove warnings-as-errors compiler switch (-WX), not recommended
c) switch to Visual Studio 2013
BrokenOpCode
6 posts
Compiling - errors from previous local declaration
They are new warnings generated in VS2015. HMH uses VS2013.

For a quick fix you can turn off those specific warnings with /wd4456 /wd4244
Tim
13 posts
Compiling - errors from previous local declaration
Edited by Tim on
Ah, thank you. It works!
This community is really fast and helpful.
6 posts
None
Compiling - errors from previous local declaration
I am getting similar problem with compiling source from episode 20. It is:
1
warning c4456: declaration of 'PlayCursor' hides previous local declaration


My setup is similar (VS15) and I understand the reason for this error. But if Casey will read this post I was wandering what is his stand on this warning. Should I just delete the inner declaration or hide this warning as 'not really needed'.
Mārtiņš Možeiko
2559 posts / 2 projects
Compiling - errors from previous local declaration
Edited by Mārtiņš Možeiko on
Whenever Casey got this kind of warning on stream, he fixed it by changing variable name. Which makes sense - otherwise in place somewhere below where both names are "available", how do you know which one do you want to reference? Compiler of course will make easy decision for you and use most recently declared one. But what if this is not what you want? I suggest C4456 warning to error, so it forces you to fix it. Same with gcc/clang (-Werror-shadow).