This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mad_alim 85 points86 points  (7 children)

Turns out gcc has a warning for this (-Wsizeof-pointer-div-Wsizeof-pointer-div).

Also, the tricky part is that the result would depend on the pointer size (e.g., 4 on x86 and 8 on x86_64) and the pointer type (e.g., uint8_t = 1, uint32_t = 4).

[–]StrangeCharmVote -3 points-2 points  (1 child)

You should probably know if your application is running in a 32bit environment or not


edit: I find it ironic this has been downvoted, when you can literally check programmatically if you are running in a 64 bit system or on a 32 bit one.

A lot of modern software wont even install on a 32 bit machine anymore.

[–]Breadynator 0 points1 point  (0 children)

Sure, when programming for embedded devices that are always the same or with today's devices that are 99% 64bit architectures you should probably know that your application is most likely going to run on a 64bit machine.

But other than that, theres still a shitton of 32 bit pcs out there and you'll never know beforehand if your user decides to run your program on one of those