看板 DFBSD_bugs 關於我們 聯絡資訊
--nextPart1821531.tXHq7XXI4y Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Thursday, 6. January 2005 10:00, Adrian Bocaniciu wrote: > As I have already mentioned in a follow-up to my recent bug report, the > essential ports net/quagga and net/zebra have been totally broken by the > use of lower-case macros in the DragonFly system headers. > > There is an old C tradition that the identifiers used in macro > definitions must be written entirely with capital letters and that no > other identifiers should be written like that. This tradition has not > been caused by esthetic reasons but by the need to separate the name > spaces for macros and for other identifiers. I think you are mistaking something here. Macros are traditionally written= =20 upper case if they evaluate their arguments more than one time, iirc. If you want to be portable, #define POSIX_SOURCE or what it is called and=20 don't include sys/* files. These lower case macros are usually for=20 convenience or compatibility. =46or example <netdb.h>: struct hostent { char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* host address type */ int h_length; /* length of address */ char **h_addr_list; /* list of addresses from name server */ #define h_addr h_addr_list[0] /* address, for backward compatibility */ }; as you can see, it's an often used compatibility define. and those are usua= lly=20 prefixed with an acronym from the struct (h_). Unfortunately, conflicts=20 happen, but you can't avoid it. Removing those defines would result in a mu= ch=20 larger breakage, I'd guess. > In the case of net/route.h, where I first encountered such macros, they > were used to provide alternate names for some structure members. That > can be done in a perfectly safe way without macros, by using anonymous > unions. Even if, for some very stupid reason (as the named unions were > really a mistake in the original C design) the anonymous unions have not > made their way yet into the official C standard, gcc and most other C > compilers support anonymous unions also in C, not only in C++. I'm not sure if this will always work. Could you give an example which will= =20 compile with gcc2 and gcc34 without warnings? cheers simon =2D-=20 /"\ \ / \ ASCII Ribbon Campaign / \ Against HTML Mail and News --nextPart1821531.tXHq7XXI4y Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQBB3QYkr5S+dk6z85oRApbSAKCRGhGzuErRXh4tf1ztDxd3T28tJgCdGt5A Kw5EJWoyIYEG+JtaNAl3ZXM= =lr59 -----END PGP SIGNATURE----- --nextPart1821531.tXHq7XXI4y--