Subject: Re: man pages & style guide
To: Julian Bean <jules@mailbox.co.uk>
From: J.T. Conklin <jconklin@netcom.com>
List: current-users
Date: 03/07/1996 11:11:56
> > So prototype function arguments in system headers must either not have
> > names, or have names in the implementers namespace.
> > 
> So, *never* have any #defines before system header files, unless you
> know exactly what you are doing.  It could have horrible
> consequences in many ways:

If implementations were free to use identifiers in the users namespace
in function prototypes in system headers, it would be not be possible
to safely #define anything before including any of those headers.  But
"portable" programs do it all the time, as they often rely on feature
test macros to determine what headers to include.

An example from gdb_string.h:
	#ifdef STDC_HEADERS
	#include <string.h>
	#else
	# ifdef HAVE_STRING_H
	#   include <string.h>
	# else
	#   include <strings.h>
	# endif
	extern char *strchr();
	.
	.
	.
	#endif

Gdb_string.h determines which headers to include based on the values
of the feature test macros STDC_HEADERS and HAVE_STRING_H (determined
by autoconf).  If we weren't allowed to #define those macros before
including system headers, I can't see any other alternative than to
have our source file generated by some other pre-processor.  yuck.


> #define pid_t void
> #include <sys/types.h>

> #define rabbit_t double
> #include <sys/types.h>
> 
> Which works absolutely fine until someone tries to port your code to
> some obscure operating system which has a rabbit_t in its
> sys/types.h

Since we know that *_t is a reserved identifier when <sys/types.h>
included, so we deserve to get bitten if we use rabbit_t.  I don't
feel the same about identifiers in the user's namespace.

	--jtc