Check if uint64_t is defined

Type uint64_tcannot be defined on 32-bit platforms, but type code

int main() {
  uint64_t i = 0;
}

may cause type compilation errors incomplete type.

Is there a preprocessor directive to check for availability uint64_t? Any other way to check if a type is set?

+4
source share
1 answer

I believe a reasonable approach is to check if a related macro is installed UINT64_MAX, for example.

#include <cstdint> /* don't forget to include */

...

#ifdef UINT64_MAX
    ...
#endif

AFAIK , . C99, 7.18.2 ( ++ , ):

- <stdint.h>. 7.18.1.

+7

Source: https://habr.com/ru/post/1548172/


All Articles