Get integer bytes order in a compile time

Discussion in 'C Programming' started by Alexander Veremyev, May 23, 2005.

  1. Hi All,

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

    With best regards,
    Alexander Veremyev.
     
    Alexander Veremyev, May 23, 2005
    #1
    1. Advertising

  2. Alexander Veremyev

    Eric Sosman Guest

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


    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, May 23, 2005
    #2
    1. Advertising

  3. Alexander Veremyev

    baumann@pan Guest

    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:
    > Hi All,
    >
    > Is there any possibility in a C standard to get integer bytes order
    > in a compile time?
    >
    > With best regards,
    > Alexander Veremyev.
     
    baumann@pan, May 27, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Collins
    Replies:
    3
    Views:
    6,091
    Jason Collins
    Feb 18, 2004
  2. mrby

    4-bytes or 8-bytes alignment?

    mrby, Nov 2, 2004, in forum: C Programming
    Replies:
    8
    Views:
    448
    Mark McIntyre
    Nov 2, 2004
  3. Nagaraj
    Replies:
    1
    Views:
    913
    Lionel B
    Mar 1, 2007
  4. Carter
    Replies:
    2
    Views:
    527
    Carter
    Mar 4, 2009
  5. Mok-Kong Shen
    Replies:
    24
    Views:
    405
    Grant Edwards
    Jun 12, 2013
Loading...

Share This Page