new compilation warnings in NaviCube.cpp

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Post Reply
User avatar
uwestoehr
Posts: 1425
Joined: Sun Jan 27, 2019 3:21 am

new compilation warnings in NaviCube.cpp

Post by uwestoehr » Tue Apr 07, 2020 10:27 pm

Compiling master I get now these new warnings:

Code: Select all

D:\FreeCADGit\src\Gui\NaviCube.cpp(977): warning C4305: 'argument': truncation from 'double' to 'GLfloat'
9>D:\FreeCADGit\src\Gui\NaviCube.cpp(978): warning C4305: 'argument': truncation from 'double' to 'GLfloat'
9>D:\FreeCADGit\src\Gui\NaviCube.cpp(986): warning C4305: 'argument': truncation from 'double' to 'GLfloat'
9>D:\FreeCADGit\src\Gui\NaviCube.cpp(987): warning C4305: 'argument': truncation from 'double' to 'GLfloat'
9>D:\FreeCADGit\src\Gui\NaviCube.cpp(995): warning C4305: 'argument': truncation from 'double' to 'GLfloat'
9>D:\FreeCADGit\src\Gui\NaviCube.cpp(996): warning C4305: 'argument': truncation from 'double' to 'GLfloat'
triplus, since you added the code, can you please have a look?
triplus wrote: .
adrianinsaval
Posts: 317
Joined: Thu Apr 05, 2018 5:15 pm

Re: new compilation warnings in NaviCube.cpp

Post by adrianinsaval » Tue Apr 07, 2020 11:35 pm

https://www.daniweb.com/programming/sof ... e-to-float
According to this adding an f at the end of the numbers should remove the warnings by telling the compiler you just want a float not a double. I don't know much C++ and just wanted to satisfy my curiosity so take it with a grain of salt
vocx
Posts: 3958
Joined: Thu Oct 18, 2018 9:18 pm

Re: new compilation warnings in NaviCube.cpp

Post by vocx » Wed Apr 08, 2020 3:31 am

Lines 977-978

Code: Select all

glVertex3f(-1.1 , -1.1, -1.1);
glVertex3f(+0.5 , -1.1, -1.1);
Lines 986-987

Code: Select all

glVertex3f(-1.1 , -1.1, -1.1);
glVertex3f(-1.1 , +0.5, -1.1);
Lines 995-996

Code: Select all

glVertex3f(-1.1 , -1.1, -1.1);
glVertex3f(-1.1 , -1.1, +0.5);
I think every 1.1 can be substituted by a, as we have this definition.

Code: Select all

float a=1.1f;
And then a new definition could be made for 0.5 as well.

Code: Select all

float b=0.5f;
Always add the important information to your posts if you need help.
To support the documentation effort, and code development, your donation is appreciated: paypal.
triplus
Posts: 9425
Joined: Mon Dec 12, 2011 4:45 pm

Re: new compilation warnings in NaviCube.cpp

Post by triplus » Sun Apr 19, 2020 3:59 pm

Will take a look in the following days.
triplus
Posts: 9425
Joined: Mon Dec 12, 2011 4:45 pm

Re: new compilation warnings in NaviCube.cpp

Post by triplus » Mon Apr 20, 2020 7:03 pm

uwestoehr wrote:
Tue Apr 07, 2020 10:27 pm
Compiling master I get now these new warnings:
Thanks for reporting. I took a look on Travis and indeed on Windows builds such compiler warnings are detected. Hopefully the following PR will resolve the issue.

https://github.com/FreeCAD/FreeCAD/pull/3372
User avatar
uwestoehr
Posts: 1425
Joined: Sun Jan 27, 2019 3:21 am

Re: new compilation warnings in NaviCube.cpp

Post by uwestoehr » Mon Apr 20, 2020 10:45 pm

triplus wrote:
Mon Apr 20, 2020 7:03 pm
Hopefully the following PR will resolve the issue: https://github.com/FreeCAD/FreeCAD/pull/3372
Yes, this fixes it. Thank you.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests