This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [avr-gcc-list] Re: AVR byte swap optimization


Hi,

and it is possible to use an anonymous struct:

static inline uint16_t bswap_16_inline(uint16_t x)
{
  union {
    uint16_t x;
    struct {
      uint8_t a, b;
    };
  } in, out;
  in.x = x;
  out.a = in.b;
  out.b = in.a;
  return out.x;
}

Regards,

Nils


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]