STDC_ENDIAN_LITTLE, STDC_ENDIAN_BIG, STDC_ENDIAN_NATIVE - cppreference.com (original) (raw)

Defined in header <stdbit.h>
#define __STDC_ENDIAN_LITTLE__ /* implementation-defined */ (1) (since C23)
#define __STDC_ENDIAN_BIG__ /* implementation-defined */ (2) (since C23)
#define __STDC_ENDIAN_NATIVE__ /* implementation-defined */ (3) (since C23)

Indicates the endianness of all scalar types:

[edit] Example

#include <stdbit.h> #include <stdio.h>   int main() { switch(STDC_ENDIAN_NATIVE) { case STDC_ENDIAN_LITTLE: printf("__STDC_ENDIAN_LITTLE__\n"); break; case STDC_ENDIAN_BIG: printf("__STDC_ENDIAN_BIG__\n"); break; default: printf("mixed-endian\n"); } return STDC_ENDIAN_NATIVE; }

Possible output:

[edit] See also