int vs ssize_t and u-inst vs size_t
Nusret Taşçı
nusi at sofha.de
Tue Aug 1 09:31:44 PDT 2006
Hi,
When compiling wxWidgets for x64 with VS2005, I get 469 warnings which
look like:
conversion from 'size_t' to 'int', possible loss of data.
So I thought that this would be a great opportunity to fix these
warnings and contribute to the project.
Unfortunately only a few of these warnings are _very_ local, like:
int i = aString.length();
return i>bString.length();
While the 32 bit compiler doesn't warn about that, the 64 bit one does.
These kind of warnings are fixable, and I guess no one will argue
against fixing them.
Some of these local type of warnings require understanding of followup
code, because this signed/unsigned conversion may influence following
calculations. Fixing these may result in broken code - I don't have the
heart to change these kind of warnings.
For the other warnings - for the greatest part of the warnings, it would
be required to change function declarations, which may require to fix
derived classes (and samples).
For example: ..\..\include\wx/richtext/richtextbuffer.h declares a lot
of input/output values and member variables as long or int. For example
GetParagraphCount() returns a signed int where I'd say that it should
return size_t.
While continuing with my observations I concluded that even a lot of
very basic and 'old' classes would need a change.
wxString::Find() returns int, while find() returns size_t. There are
some other functions similar to Find() which should return size_t instead.
And when I finally saw that wxSize uses 'int' for 'x' and 'y', I decided
to write this eMail and ask the wx-developers to please use ssize_t and
size_t more often (and where appropriate) as they're IMHO more - well
more portable maybe? Changing wxSize to use ssize_t would be ideal, but
I guess the risk to break existing code on not so common compilers may
be too big, so I don't dare to ask.
Is there anything I can do to 'fix' these warnings in CVS_HEAD? I'd post
the buildlog with linenumbers etc, but it's 39k in size, it may be too
big for this list.
There are 2 other possible solutions for these warnings. C-style-cast
them or ignore them. I hope no one considers this to be a real option.
On the other hand, it's up to you to ignore this and let me live with my
size_t fetish. ;)
Regards,
Nusi
More information about the wx-dev
mailing list