Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      __STDC_ENDIAN_LITTLE__, __STDC_ENDIAN_BIG__, __STDC_ENDIAN_NATIVE__

      From cppreference.com
      <c‎ |numeric
       
       
       
       
      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 theendianness of allscalar types:

      • If all scalar types are little-endian,__STDC_ENDIAN_NATIVE__ equals__STDC_ENDIAN_LITTLE__.
      • If all scalar types are big-endian,__STDC_ENDIAN_NATIVE__ equals__STDC_ENDIAN_BIG__.
      • If the platform uses neither little-endian nor big-endian,__STDC_ENDIAN_NATIVE__ equals neither__STDC_ENDIAN_BIG__ nor__STDC_ENDIAN_LITTLE__.
      • The values of the integer constant expressions for__STDC_ENDIAN_BIG__ and__STDC_ENDIAN_LITTLE__ are not equal.

      [edit]Example

      Run this code
      #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:

      mixed-endian

      [edit]See also

      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/numeric/bit/endian&oldid=178957"

      [8]ページ先頭

      ©2009-2025 Movatter.jp