[flac-dev] How to check for 64-bit CPU?

lvqcl lvqcl.mail at gmail.com
Mon Dec 28 11:35:10 PST 2015

In stream_encoder.c there's the following code:

  #if defined FLAC__CPU_X86_64 /* and other 64-bit arch, too */
      if(mean <= 0x80000000/512) { /* 512: more or less optimal for both 16- and 24-bit input */
      if(mean <= 0x80000000/8) { /* 32-bit arch: use 32-bit math if possible */

A) How to properly check for 64-bit architectures?
I can check for "defined FLAC__CPU_X86_64" or "defined _WIN64".
Is it possible to use SIZEOF_VOIDP? such as "#if SIZEOF_VOIDP == 8" ?

B) Does it make sense to put the following code into some header file?
(if yes, what header file should be used?)

  #if (defined FLAC__CPU_X86_64) || ...something else here...
  #define FLAC__64BIT_ARCH 1
  #undef FLAC__64BIT_ARCH

More information about the flac-dev mailing list