[CMake] Detecting 32/64 bit systems

Rolf Eike Beer eike at sf-mail.de
Mon Feb 14 04:35:26 EST 2011


> I have done the same thing myself, using size of INT instead of P which is
> of course following the exact same logic.
> After attempting several strategies I found this one to be the safest way
> to detect 32/64bit systems, so I recommend using SIZEOF as well.

sizeof(int) is 4 on basically all systems I have ever seen (ignoring those
16bit machines of 286 areas or things like that) so this test is basically
useless. Also testing for sizeof(long) will get you into trouble as this 8
for Un*x64 but 4 for Win64. The best way is usually sizeof(void*) even if
there are programming model where you would get a 32 bit pointer even in a
64 bit executable but those have to be explicitely enabled and are barely
ever used from my experience.

Eike


More information about the CMake mailing list