Re: [osg-users] Use namespace...
Thanks for the helpful replies! So it is just a matter of preference, i guess :) -Masoug ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Use namespace...
Hi, Just curious, I noticed that in a lot of the code, we use stuff like osg::someFunctio() and etc... Could we use a namespace using namespace osg; to avoid having to write osg:: every single time? THANKS!! -Masoug ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Use namespace...
Yes you can, however OSG uses simple names that will likely also be used in other projects (e.g. Array, Node, Group etc.) so it's quite likely you'll get name conflicts if you use another library which uses the same class names. I've had developers making similar complaints to me, so as a compromise we do using somenamespace::SomeClass; using somenamespace::SomeFunction; etc. for things that are used very frequently. That way it will be less of a big deal to change the code if we start using a library that uses the same class names. On 13 April 2010 17:12, mas oug mas...@gmail.com wrote: Hi, Just curious, I noticed that in a lot of the code, we use stuff like osg::someFunctio() and etc... Could we use a namespace using namespace osg; to avoid having to write osg:: every single time? THANKS!! -Masoug ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Use namespace...
I have found it much safer/easier (in the long run) to not collapse the namespaces. It's a lot of trouble to go back and correct the problem when you start integrating other toolkits. Just my 2 cents worth. On 13 April 2010 17:12, mas oug mas...@gmail.com wrote: Hi, Just curious, I noticed that in a lot of the code, we use stuff like osg::someFunctio() and etc... Could we use a namespace using namespace osg; to avoid having to write osg:: every single time? THANKS!! -Masoug ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Use namespace...
Hi, On 13/04/10 9:12 , mas oug wrote: Just curious, I noticed that in a lot of the code, we use stuff like osg::someFunctio() and etc... Could we use a namespace using namespace osg; to avoid having to write osg:: every single time? Of course you can use a 'using namespace osg' in the implementation files on your own project if that makes it more comfortable for you. Just don't put them in a header file as this is a no-no, it defeats the purpose of namespaces in the first place. Like Ben Cain I tend to not do that since it makes the code easier to read since it's obvious where a class/function comes from. Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org