Horde3D

Next-Generation Graphics Engine
It is currently 22.11.2024, 18:44

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: 01.04.2009, 16:49 
Offline

Joined: 01.04.2009, 16:46
Posts: 9
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


Top
 Profile  
Reply with quote  
PostPosted: 01.04.2009, 21:02 
Offline

Joined: 15.06.2008, 11:21
Posts: 166
Location: Germany
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.


Top
 Profile  
Reply with quote  
PostPosted: 02.04.2009, 21:26 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
If one of you guys has a little patch we are happy to integrate it :)


Top
 Profile  
Reply with quote  
PostPosted: 02.04.2009, 22:54 
Offline

Joined: 01.04.2009, 16:46
Posts: 9
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 722 times
Top
 Profile  
Reply with quote  
PostPosted: 04.04.2009, 14:05 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Thanks, but this just seems to disable the warning and does not fix it.


Top
 Profile  
Reply with quote  
PostPosted: 04.04.2009, 16:10 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
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.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 04.04.2009, 16:40 
Offline

Joined: 01.04.2009, 16:46
Posts: 9
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
Top
 Profile  
Reply with quote  
PostPosted: 04.04.2009, 19:37 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
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.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 05.04.2009, 08:49 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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
Top
 Profile  
Reply with quote  
PostPosted: 05.04.2009, 10:16 
Offline

Joined: 01.04.2009, 16:46
Posts: 9
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


Top
 Profile  
Reply with quote  
PostPosted: 05.04.2009, 10:51 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Thanks for testing it. I committed it to the SVN.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group