Jump to content
XCOMUFO & Xenocide

Let's Fight Ugly ::string


Recommended Posts

Opening this topic to clean our code from uglyness of

::String

declarations. Now, thanks to that little code snippet, we no longer need to specify String's scope. ::String explicitly tells the compiler that we want String type that is defined in global scope (and that is our String type). Since two more projects we're using have classes with the same names, but in other namespaces (CEGUI::String and Ogre::String), this led to ambiguous symbol errors when one of us wanted to use

using namespace Ogre; // or CEGUI

to ease writting. Since our code is in Xenocide::Common/Core/UI namespaces, after saying using namespace Ogre in example, we had in our namespace equal access to String types defined in Ogre or CEGUI and in global scope. This led to errors when we had written String when declaring type. Solution was to explicitly specify which type we want to use, that is writting the ugly ::String stuff. This led to errors on GCC, since GCC treats <: as so we were forced to write>

TemplateClass< ::String>

to make code portable. This all makes code unreadable.

 

So, now that the issue is fixed, and that even if you write using namespace Ogre; you have to explicitly tell Ogre::String, we can convert all ::String to String. So, I ask you, if you see somewhere ::String - change it to String and make sure code compiles. Also, if you see using namespace Ogre; or CEGUI in all definitions of methods of some class, move that to the beginning of .cpp file. Changing ::String to String can also be done in .h files. Btw, remember that it's forbidden to use using.... declarations in header files (the ones in commonrequisites.h are there to fix ::String issue so it doesn't count ;) ).

 

Greetings,

Guyver

Edited by guyver6
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...