Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #160 Detect if 32-bit or 64-bit architecture

Execute f32() if platform is 32-bit, or f64() if platform is 64-bit.
This can be either a compile-time condition (depending on target) or a runtime detection.

if constexpr(sizeof(nullptr) == 8) {
  f64();
} else {
  f32();
}

This tests the size of a pointer.

New implementation...
< >
programming-idioms.org