Hi, great article, thank you!
By the way, I'm not a C++ developer, but as far as I'm concerned, the common primitive types like int in C++ are machine-dependent, e.g. in this line:
// int i = -8leti=-8i32;
wouldn't it be better to write fixed-width types for clarity like this instead
fun fact: I also got this wrong in my first version and thought that int is 64bit on 64bit-arch. What I found out was, that int can be 64bit, but most of the mainstream compilers will use 32bit for some reasons you can find for example in this thread here: stackoverflow.com/questions/174898...
It's really a mess in C++ :D, but you can check it out on your machine:
Hi, great article, thank you!
By the way, I'm not a C++ developer, but as far as I'm concerned, the common primitive types like
int
in C++ are machine-dependent, e.g. in this line:wouldn't it be better to write fixed-width types for clarity like this instead
Thanks.
Hey @thedenisnikulin,
fun fact: I also got this wrong in my first version and thought that
int
is 64bit on 64bit-arch. What I found out was, thatint
can be 64bit, but most of the mainstream compilers will use 32bit for some reasons you can find for example in this thread here: stackoverflow.com/questions/174898...It's really a mess in C++ :D, but you can check it out on your machine:
So
int
is "mostly good enough" for counting or accessing "array-like" types, but of course not for storing pointers or the difference of pointers.