Horde3D
http://horde3d.org/forums/

[solved] Unnecessary warninr while building on linux
http://horde3d.org/forums/viewtopic.php?f=3&t=684
Page 1 of 1

Author:  cb951303 [ 01.04.2009, 16:49 ]
Post subject:  [solved] Unnecessary warninr while building on linux

Hello, this is not a bug but I thought like sharing anyway.

gcc 4.3.2 gives a lot of this warning while building Horde 3D 1.0.0 beta 3 on linux: ...warning: deprecated conversion from string constant to ‘char*’

it's not important and it can be turned off with a simple -Wno-write-strings flag to the compiler line

cheers

Author:  phoenix64 [ 01.04.2009, 21:02 ]
Post subject:  Re: Unnecessary warninr while building on linux

I had a simple hackfix for this using some simple casts from const char* to char*, was only < 10 lines, I lost it though -.-

It's really a simple issue.

Author:  marciano [ 02.04.2009, 21:26 ]
Post subject:  Re: Unnecessary warninr while building on linux

If one of you guys has a little patch we are happy to integrate it :)

Author:  cb951303 [ 02.04.2009, 22:54 ]
Post subject:  Re: Unnecessary warninr while building on linux

sure

PS: Note that according to cmake docs IF(UNIX) also takes care of MacOS (which uses gcc too)

Attachments:
File comment: apply on horde3d root dir with patch -p0
gccwpatch.patch [838 Bytes]
Downloaded 723 times

Author:  marciano [ 04.04.2009, 14:05 ]
Post subject:  Re: Unnecessary warninr while building on linux

Thanks, but this just seems to disable the warning and does not fix it.

Author:  swiftcoder [ 04.04.2009, 16:10 ]
Post subject:  Re: Unnecessary warninr while building on linux

cb951303 wrote:
gcc 4.3.2 gives a lot of this warning while building Horde 3D 1.0.0 beta 3 on linux: ...warning: deprecated conversion from string constant to ‘char*’
String constants are typically not writeable (and may be shared), so you should always treat them as const char *
Quote:
it's not important and it can be turned off with a simple -Wno-write-strings flag to the compiler line
That merely hides the problem, without fixing it. If you pass a string constant to a function as char *, then the function is allowed to modify the string, and this will cause a segfault.

We should track down all string functions, and make sure that they take const char * unless they actually modify the string.

Author:  cb951303 [ 04.04.2009, 16:40 ]
Post subject:  Re: Unnecessary warninr while building on linux

marciano wrote:
Thanks, but this just seems to disable the warning and does not fix it.


it's really a gcc dumbness more than an error but anyway :D here is the fixed code patch against svn

Attachments:
cstr2chr.patch [968 Bytes]
Downloaded 712 times

Author:  swiftcoder [ 04.04.2009, 19:37 ]
Post subject:  Re: Unnecessary warninr while building on linux

cb951303 wrote:
it's really a gcc dumbness more than an error but anyway :D
It is an error - in fact, failure_reason should probably be a const char * as well. Desktop operating systems tend to be very lenient about things such as writing into sting constants, but you won't be so lucky everywhere.

Author:  Volker [ 05.04.2009, 08:49 ]
Post subject:  Re: Unnecessary warninr while building on linux

So is there any reason why we don't use const char* everywhere?

Can someone with a GCC and/or MinGW compiler test the following patch?

Attachments:
cstr2chr.patch [1.61 KiB]
Downloaded 769 times

Author:  cb951303 [ 05.04.2009, 10:16 ]
Post subject:  Re: Unnecessary warninr while building on linux

Volker wrote:
So is there any reason why we don't use const char* everywhere?

Can someone with a GCC and/or MinGW compiler test the following patch?


you're right there is no reason to make unnecessary type casts :o
it compiles without warnings with gcc 4.3.2

Code:
Scanning dependencies of target Horde3D
[  1%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egAnimatables.o
[  3%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egAnimation.o
[  4%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egCamera.o
[  6%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egCom.o
[  8%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egExtensions.o
[  9%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egGeometry.o
[ 11%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egLight.o
[ 13%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egMain.o
[ 14%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egMaterial.o
[ 16%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egModel.o
[ 18%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egModules.o
[ 19%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egParticle.o
[ 21%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egPipeline.o
[ 22%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egPrimitives.o
[ 24%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egRendererBase.o
[ 26%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egRenderer.o
[ 27%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egResource.o
[ 29%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egScene.o
[ 31%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egSceneGraphRes.o
[ 32%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egShader.o
[ 34%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/egTextures.o
[ 36%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/utImage.o
[ 37%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/utOpenGL.o
[ 39%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/__/Shared/utXMLParser.o
[ 40%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/__/__/__/Extensions/Terrain/Source/terrain.o
[ 42%] Building CXX object Horde3D/Source/Horde3DEngine/CMakeFiles/Horde3D.dir/__/__/__/Extensions/Terrain/Source/extension.o
Linking CXX shared library libHorde3D.so
[ 42%] Built target Horde3D
Scanning dependencies of target Horde3DUtils
[ 44%] Building CXX object Horde3D/Source/Horde3DUtils/CMakeFiles/Horde3DUtils.dir/main.o
Linking CXX shared library libHorde3DUtils.so
[ 44%] Built target Horde3DUtils
Scanning dependencies of target ColladaConv
[ 45%] Building CXX object Horde3D/Source/ColladaConverter/CMakeFiles/ColladaConv.dir/converter.o
[ 47%] Building CXX object Horde3D/Source/ColladaConverter/CMakeFiles/ColladaConv.dir/daeMain.o
[ 49%] Building CXX object Horde3D/Source/ColladaConverter/CMakeFiles/ColladaConv.dir/main.o
[ 50%] Building CXX object Horde3D/Source/ColladaConverter/CMakeFiles/ColladaConv.dir/optimizer.o
[ 52%] Building CXX object Horde3D/Source/ColladaConverter/CMakeFiles/ColladaConv.dir/utils.o
[ 54%] Building CXX object Horde3D/Source/ColladaConverter/CMakeFiles/ColladaConv.dir/__/Shared/utXMLParser.o
Linking CXX executable ../../Binaries/Linux/ColladaConv
[ 54%] Built target ColladaConv
Scanning dependencies of target glfw
[ 55%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/enable.o
[ 57%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/fullscreen.o
[ 59%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/glext.o
[ 60%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/image.o
[ 62%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/init.o
[ 63%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/input.o
[ 65%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/joystick.o
[ 67%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/stream.o
[ 68%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/tga.o
[ 70%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/thread.o
[ 72%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/time.o
[ 73%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/window.o
[ 75%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/x11/x11_enable.o
[ 77%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/x11/x11_fullscreen.o
[ 78%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/x11/x11_glext.o
[ 80%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/x11/x11_init.o
[ 81%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/x11/x11_joystick.o
[ 83%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/x11/x11_keysym2unicode.o
[ 85%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/x11/x11_thread.o
[ 86%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/x11/x11_time.o
[ 88%] Building C object Horde3D/Dependencies/Source/glfw/CMakeFiles/glfw.dir/x11/x11_window.o
Linking C static library libglfw.a
[ 88%] Built target glfw
Scanning dependencies of target Chicago
[ 90%] Building CXX object Horde3D/Samples/Chicago/CMakeFiles/Chicago.dir/app.o
[ 91%] Building CXX object Horde3D/Samples/Chicago/CMakeFiles/Chicago.dir/crowd.o
[ 93%] Building CXX object Horde3D/Samples/Chicago/CMakeFiles/Chicago.dir/main.o
Linking CXX executable ../../Binaries/Linux/Chicago
[ 93%] Built target Chicago
Scanning dependencies of target Knight
[ 95%] Building CXX object Horde3D/Samples/Knight/CMakeFiles/Knight.dir/app.o
[ 96%] Building CXX object Horde3D/Samples/Knight/CMakeFiles/Knight.dir/main.o
Linking CXX executable ../../Binaries/Linux/Knight
[ 96%] Built target Knight
Scanning dependencies of target Terrain
[ 98%] Building CXX object Extensions/Terrain/Sample/CMakeFiles/Terrain.dir/app.o
[100%] Building CXX object Extensions/Terrain/Sample/CMakeFiles/Terrain.dir/main.o
Linking CXX executable ../../../Horde3D/Binaries/Linux/Terrain
[100%] Built target Terrain

Author:  Volker [ 05.04.2009, 10:51 ]
Post subject:  Re: Unnecessary warninr while building on linux

Thanks for testing it. I committed it to the SVN.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/