Handmade Hero » Forums » Code » Compiling - errors from previous local declaration
epsilon
Tim
13 posts
#5248 Compiling - errors from previous local declaration
3 years, 4 months ago

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!
mmozeiko
Mārtiņš Možeiko
1916 posts / 1 project
#5250 Compiling - errors from previous local declaration
3 years, 4 months ago Edited by Mārtiņš Možeiko on Nov. 25, 2015, 5:05 a.m.

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
BrokenOpCode
6 posts
#5251 Compiling - errors from previous local declaration
3 years, 4 months ago

They are new warnings generated in VS2015. HMH uses VS2013.

For a quick fix you can turn off those specific warnings with /wd4456 /wd4244
epsilon
Tim
13 posts
#5252 Compiling - errors from previous local declaration
3 years, 4 months ago Edited by Tim on Nov. 25, 2015, 5:19 p.m.

Ah, thank you. It works!
This community is really fast and helpful.
alfred
6 posts

None

#17266 Compiling - errors from previous local declaration
2 months, 3 weeks ago

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'.

None
mmozeiko
Mārtiņš Možeiko
1916 posts / 1 project
#17271 Compiling - errors from previous local declaration
2 months, 3 weeks ago Edited by Mārtiņš Možeiko on Jan. 28, 2019, 5:17 p.m.

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).