bluesky idea: __attribute__ (netorder)

Jamie Lokier egcs@tantalophile.demon.co.uk
Sat Sep 5 21:16:00 GMT 1998


On Sat, Sep 05, 1998 at 03:31:05AM +0200, Carlo Wood wrote:
> | Perhaps __a__ ({big,little}endian) might make more sense...
> 
> __a__ (network) makes more sense as it would make the
> source code portable between different endian machines
> without changes or the need of #ifdef's.

__a__ (network) would also emit the warnings even on machines that
already use network byte order.  __{big,little}endian__ might not.

How about generalising this feature to support arbitrary markers, which
must match up when a value is moved around otherwise a warning it
produced?

I mean like:

struct sockaddr_in {
  ...
  unsigned short sin_port __attribute__ ((property (network)));
  ...
};

extern u_int16_t
ntohs ((u_int16_t __attribute__ ((property (network))) __netshort));

extern u_int16_t __attribute__ ((property (network)))
htons ((u_int16_t __hostshort));

Just a thought for the pot.  I know this brings up many difficult issues.
-- Jamie



More information about the Gcc mailing list