Snek Build warnings

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
User avatar
Multibyte
Posts: 42
Joined: September 17th, 2013, 5:55 am
Location: USA

Snek Build warnings

Post by Multibyte » March 27th, 2017, 5:36 pm

I just cloned Snek from https://github.com/planetchili/snek to start Tut17. I am getting the following 'Warnings' while building.

In a previous tutorial Chili showed conversion between 'floats' and 'ints' and how they can cause warnings. These seem to be the same thing with 'doubles' and 'floats'.

I wonder if I should just ignore them for now since game seems to be working fine. On the other hand, as Chili was saying, these are filling the build window and may potentially make other warnings harder to notice.

I am using VS2017 and both SDK 10 and SDK 8.1 are installed. It seems Chili was using VS2015 while making these tutorials and samples. Could that be the reason? How to fix it?

Code: Select all

1>------ Build started: Project: Engine, Configuration: Debug x64 ------
1>compilation header save succeeded; see C:\Users\user\Documents\Visual Studio 2017\Projects\Snek\Engine\FramebufferPS.shh
1>compilation header save succeeded; see C:\Users\user\Documents\Visual Studio 2017\Projects\Snek\Engine\FramebufferVS.shh
1>Board.cpp
1>DXErr.cpp
1>FrameTimer.cpp
1>Game.cpp
1>Goal.cpp
1>Graphics.cpp
1>Keyboard.cpp
1>Main.cpp
1>MainWindow.cpp
1>Mouse.cpp
1>Snake.cpp
1>Sound.cpp
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.10.25017\include\random(3790): warning C4244: '=': conversion from 'double' to 'float', possible loss of data (compiling source file Game.cpp)
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.10.25017\include\random(3725): note: see reference to function template instantiation 'float std::normal_distribution<float>::_Eval<_Engine>(_Engine &,const std::normal_distribution<float>::param_type &,bool)' being compiled
1>        with
1>        [
1>            _Engine=std::mt19937
1>        ] (compiling source file Game.cpp)
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.10.25017\include\random(3725): note: see reference to function template instantiation 'float std::normal_distribution<float>::_Eval<_Engine>(_Engine &,const std::normal_distribution<float>::param_type &,bool)' being compiled
1>        with
1>        [
1>            _Engine=std::mt19937
1>        ] (compiling source file Game.cpp)
1>c:\users\user\documents\visual studio 2017\projects\snek\engine\soundeffect.h(58): note: see reference to function template instantiation 'float std::normal_distribution<float>::operator ()<T>(_Engine &)' being compiled
1>        with
1>        [
1>            T=std::mt19937,
1>            _Engine=std::mt19937
1>        ] (compiling source file Game.cpp)
1>c:\users\user\documents\visual studio 2017\projects\snek\engine\soundeffect.h(58): note: see reference to function template instantiation 'float std::normal_distribution<float>::operator ()<T>(_Engine &)' being compiled
1>        with
1>        [
1>            T=std::mt19937,
1>            _Engine=std::mt19937
1>        ] (compiling source file Game.cpp)
1>c:\users\user\documents\visual studio 2017\projects\snek\engine\game.cpp(90): note: see reference to function template instantiation 'void SoundEffect::Play<std::mt19937>(T &,float)' being compiled
1>        with
1>        [
1>            T=std::mt19937
1>        ]
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.10.25017\include\random(3793): warning C4244: '=': conversion from 'double' to 'float', possible loss of data (compiling source file Game.cpp)
1>SpriteCodex.cpp
1>Engine.vcxproj -> C:\Users\user\Documents\Visual Studio 2017\Projects\Snek\x64\Debug\Engine.exe
1>Engine.vcxproj -> C:\Users\user\Documents\Visual Studio 2017\Projects\Snek\x64\Debug\Engine.pdb (Partial PDB)
1>Done building project "Engine.vcxproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Snek Build warnings

Post by albinopapa » March 27th, 2017, 7:37 pm

There are a few lines in Game.cpp that kind of confuse me

sfxEat.Play( rng,0.8f );
sfxSlither.Play( rng,0.08f );

Sound::Play expects a float, and Chili passes a random number engine ( std::mt19937 ). If this is valid, my only guess is there is an implicit conversion from the engine type to a float
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Snek Build warnings

Post by chili » March 28th, 2017, 1:12 am

That's not sound, it's a SoundEffect. It plays sounds effects randomly from a bank of possibilities, with a random distribution of frequency detuning.

I'll have to look into this. Could be a change in the std lib implementation of VS2017.
Chili

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Snek Build warnings

Post by chili » March 28th, 2017, 12:54 pm

Just looked into this. Might be a minor bug? in std::normal_distribution<> in the 2017 standard library implementation. Some variable in the class is being defined as double instead of <T> it seems... :/
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Snek Build warnings

Post by albinopapa » March 28th, 2017, 11:23 pm

I think it's defined as
template<class T = double>

as a default if one isn't provided, at least that's the case for vs2015 when I looked at header yesturday
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Snek Build warnings

Post by chili » March 29th, 2017, 2:08 am

Yeah, probably. But that has no impact in this situation ;)
Chili

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Snek Build warnings

Post by chili » March 30th, 2017, 8:17 am

Looks like the fix has been made and it is pending release. We did it fam.
Attachments
unknown.png
unknown.png (30.58 KiB) Viewed 2872 times
Chili

User avatar
Multibyte
Posts: 42
Joined: September 17th, 2013, 5:55 am
Location: USA

Re: Snek Build warnings

Post by Multibyte » March 30th, 2017, 8:27 pm

Awesome! ;) It is good to know I wasn't just being dumb. :mrgreen:

Post Reply