<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Use BYTE_ORDER to determine byte order"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=94570#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Use BYTE_ORDER to determine byte order"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=94570">bug 94570</a>
              from <span class="vcard"><a class="email" href="mailto:jasper@humppa.nl" title="Jasper Lievisse Adriaanse <jasper@humppa.nl>"> <span class="fn">Jasper Lievisse Adriaanse</span></a>
</span></b>
        <pre>(In reply to Eduardo Lima (Etrunko) from <a href="show_bug.cgi?id=94570#c1">comment #1</a>)
<span class="quote">> --- spice/macros.h.orig        Thu Mar 10 15:14:49 2016
> +++ spice/macros.h Wed Mar 16 14:18:03 2016
> @@ -381,6 +381,17 @@
>  #define SPICE_ENDIAN_BIG    1234
>  #define SPICE_ENDIAN_PDP    2143
>  
> +/* Lets see if we can use a standard header first... */
> +#if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) \
> +    && defined(BIG_ENDIAN)
> +#  include <machine/endian.h>
> +#  if BYTE_ORDER == LITTLE_ENDIAN
> +#    define SPICE_ENDIAN SPICE_ENDIAN_LITTLE
> +#  elif BYTE_ORDER == BIG_ENDIAN
> +#    define SPICE_ENDIAN SPICE_ENDIAN_BIG
> +#  endif
> +#endif
> +

> So, instead of relying on those defined macros to include that header, why
> don't you check for it in configure.ac with AC_CHECK_HEADERS macro?

> You would end with something like:

> #if HAVE_MACHINE_ENDIAN_H
>    #include <machine/endian.h>
> ...
> #endif</span >

That won't work out of the box though, as macros.h is a public header. So all
projects that use macros.h would have to explicitly add the AC_CHECK_HEADERS
check for machine/endian.h, no?

Taking your latter comment into account, how about something along these lines?

+#if defined(BYTE_ORDER)
+#  if BYTE_ORDER == LITTLE_ENDIAN
+#    define SPICE_ENDIAN SPICE_ENDIAN_LITTLE
+#  elif BYTE_ORDER == BIG_ENDIAN
+#    define SPICE_ENDIAN SPICE_ENDIAN_BIG
+#  endif
+#endif

This would guard the code in the sense that it won't be evaluated if endian.h
isn't already included through another header.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>