PDA

View Full Version : int instead of size_t?



rubenvb
29th December 2009, 17:42
Why in anyone's name would trolltech decide to use int (or uint or whatever) instead of the great and portable size_t? I understand there's really no need and all, but for the elegance and future portablility such a change is really nothing?

wysota
29th December 2009, 20:59
Isn't size_t a C (or even Posix/Linux/whatever) type? C++ doesn't use size_t, as far as I know.

squidge
29th December 2009, 21:16
C++ does use size_t, and size_t is normally implemented on a platform basis. 'int' is bad form as it doesn't specify the size (it could be 8, 16, 32 or 64 bits, depending on platform), and can't be changed on a platform basis. eg. when 'int' is 16-bits, but it's perfectly acceptable to move > 64KB of data, you can't change it to 'unsigned long' easily where you can with size_t.

Considering how much Qt is multi-platform, I am suprised it doesn't use size_t, but as of yet, I've not had a problem, as it's always ARM and above, so 'int' is always at least 32-bits.

wysota
29th December 2009, 23:08
C++ does use size_t,
True, I just grepped my includes :)


Considering how much Qt is multi-platform, I am suprised it doesn't use size_t, but as of yet, I've not had a problem, as it's always ARM and above, so 'int' is always at least 32-bits.

Maybe some (one?) of the supported platform does (used to?) have size_t defined incorrectly?

BTW. It seems that Qt does use size_t in some places. So maybe this is just a mistake made in 4.0 and now it's all about providing backwards compatibility.

fispy
27th April 2017, 11:49
The reason I answer is pure rage.


C++ does use size_t

Of course there is std::size_t (in the header cstddef for instance), in fact its a very important builtin type and it exists since the first official standard from 1998.

I cannot believe to see

void QString::realloc(int alloc)

This is simply wrong, not just horribly bad, its wrong! I am now suffering from problems related to that - don't ask why there is a need for more than 2GB in a string, there just is.

As I can see, all of Qt's code is full of such things, its horrible!

d_stranz
27th April 2017, 20:51
File a bug report. These things -do- get fixed, especially if you can provide a valid use case for the change.

You also have the Qt source code, so you can make the change yourself if the wheels at The Qt Company turn too slowly for you.