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.

import "strconv"
if strconv.IntSize==32 {
	f32()
}
if strconv.IntSize==64 {
	f64()
}
begin
  {$ifdef cpu64}
  f64;
  {$endif}
  {$ifdef cpu32}
  f32;
  {$endif}
end.
match std::mem::size_of::<&char>() {
32 => _f32(),
64 => _f64(),
_ => {},
}

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

programming-idioms.org