size-t

How to avoid problems with size_t and int types in 64bit C++ builds?

Today I made a 64bit build of my project for the first time. Basically it compiled, linked and ran ok, except for warnings complaining about incompatibility between the new, 64bit size_t type and the simple int type. This mostly occurs in situations like this in my code: void func(std::vector<Something> &vec) { int n = vec.size(); ...

Making size_t and wchar_t portable?

To my understanding the representation of size_t and wchar_t are completely platform/compiler specific. For instance I have read that wchar_t on Linux is now usually 32bit, but on Windows it is 16bit. Is there any way that I can standardize these to a set size (int, long, etc.) in my own code, while still maintaining backwards comparabil...

declaring the largest array using size_t

i wanted to declare a very large array. i found that the max size of an array is size_t, which is defined as UINT_MAX so i wrote the code like this int arr[UINT_MAX]; when i compile this, it says overflow in array dimension but when i write like this size_t s = UINT_MAX; int arr[s]; it compiles properly. what's the difference ...