[osg-users] 64 bit warning

Andy Skinner Andy.Skinner at mathworks.com
Fri Aug 10 06:52:38 PDT 2007


We're getting warnings on solaris 64 about truncations for methods that
return something like vector::size() (which is size_t) using type
unsigned int.  For example, TemplateArray::getNumElements():

 

unsigned int getNumElements() const { return this->size(); }

 

 

For regular methods, we may get warnings as we build OSG, but we don't
count warnings as errors as we build 3rd party stuff.  We also wrap
includes of OSG headers in macros so that we don't get warnings when our
code includes them.  This leaks out for things like template
instantiation for things like shadowing (a class has a method x(), and a
construction with an arg x, and some compilers, when set to be picky,
don't like it.)  The case I mention above (truncation as we return
size_t as an unsigned int) is also leaking out, because it is in an
inline method.

 

What do you suggest?  I'm sure this happens a lot.  We could add casts
in the methods:

 

unsigned int getNumElements() const { return static_cast<unsigned int>
(this->size()); }

 

We could redefine the method to return size_t.

 

At the moment, I'm adding all of our files to the warning exception
list.  But that won't go over well, so I'd rather not.

 

We've not been compiling with solaris with the older OSG, so I'm
probably going to experience more of this pickiness as I update OSG and
get solaris going.

 

thanks,

andy

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070810/0613dcd7/attachment.html 


More information about the osg-users mailing list