Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Compiler warnings on windows when compiling from source  (Read 5579 times)

0 Members and 1 Guest are viewing this topic.

Rogal255

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Compiler warnings on windows when compiling from source
« on: October 10, 2021, 05:36:05 pm »
Hi!
I got 5 warnings when I was compiling SFML from source on MSVC. I know that 3 of them are known (deprecated -backward compatibility) and already supressed them with compiler flags. But the remaining 2:

Quote
...\SFML\SFML\src\SFML\Graphics\Font.cpp(394): warning C4244: 'initializing': conversion from 'const int' to 'float', possible loss of data [...\SFML\SFML\build\src\SFML\Graphics\sfml-graphics.vcxproj]

...\SFML\SFML\src\SFML\Graphics\Font.cpp(395): warning C4244: 'initializing': conversion from 'const int' to 'float', possible loss of data [...\SFML\SFML\build\src\SFML\Graphics\sfml-graphics.vcxproj]

I've added explicit conversion from int to float (static_cast) in those lines and warnings are no longer presented. Is there any reason not to cast it explicitly? I saw same issues on SFML github repo during CI windows checks.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Compiler warnings on windows when compiling from source
« Reply #1 on: October 10, 2021, 06:55:05 pm »
We've started to clean up some of these warnings, but haven't fully gotten through them all and it's not merged yet. If the piece of copy expects a conversion, then it's not really an issue if it's implicitly converted, but it's generally shown as warning, because implicit conversions are quite an issue in C++, when you don't want it, but the compiler would just (silently) convert it.

Until this is fixed, the only workaround you can get is, to set the SFML headers as "system" headers, which won't trigger warnings.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Rogal255

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Compiler warnings on windows when compiling from source
« Reply #2 on: October 10, 2021, 09:25:08 pm »
Thanks, Shall I make a PR which will get rid of those warnings? - I have already silenced them on my SFML fork.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Compiler warnings on windows when compiling from source
« Reply #3 on: October 10, 2021, 10:37:51 pm »
I'm pretty sure, I've already fixed said warnings in this PR: https://github.com/SFML/SFML/pull/1791
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Rogal255

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Compiler warnings on windows when compiling from source
« Reply #4 on: October 11, 2021, 01:05:02 am »
Yep, fixed indeed ;) Thanks

 

anything