Get integer bytes order in a compile time

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alexander Veremyev

    #1

    Get integer bytes order in a compile time

    Hi All,

    Is there any possibility in a C standard to get integer bytes order
    in a compile time?

    With best regards,
    Alexander Veremyev.
  • Eric Sosman

    #2
    Re: Get integer bytes order in a compile time



    Alexander Veremyev wrote:[color=blue]
    > Hi All,
    >
    > Is there any possibility in a C standard to get integer bytes order
    > in a compile time?[/color]

    There is no Standard macro or feature that provides
    this information. Also, it is not possible to write your
    own because the preprocessor has no notion of "address."

    You could write a "helper" program to determine the
    byte order (at its own run-time) and output its result
    in a header that the target program could #include in
    its compilation.

    --
    Eric.Sosman@sun .com

    Comment

    • baumann@pan

      #3
      Re: Get integer bytes order in a compile time


      you can write a function to detect the big /little endian of the
      processor.

      so you write other related function with the one as it can help u
      understand what endian mode it is in runtime.


      hints, think , you can define a var 0x01020304, then use each byte in
      it as an index for 4-byte-long data...

      Alexander Veremyev wrote:[color=blue]
      > Hi All,
      >
      > Is there any possibility in a C standard to get integer bytes order
      > in a compile time?
      >
      > With best regards,
      > Alexander Veremyev.[/color]

      Comment

      Working...