Subject: Re: man pages & style guide
To: J.T. Conklin <jconklin@netcom.com>
From: Julian Bean <jules@mailbox.co.uk>
List: current-users
Date: 03/07/1996 13:11:30
J.T. Conklin wrote:
> 
> > Umm...  I didn't think that function parameters went into the namespace..
> >
> >
> > int multiply(int op1,int op2);
> > int add(int op1,int op2);
> >
> > static int op1,op2;
> >
> > void func(void)
> > {
> >         int op1,op2;
> > }
> >
> > No namespace conflict there, is there?  That'll compile, surely...
> 
> Yah, it will.  Now suppose those prototypes were in a system header
> file <foo.h>.
> 
>         extern int multiply (int op1, int op2);
>         extern int add (int op1, int op2);
> 
> This could break if I redefined op1 or op2 before including <foo.h>
> 
>         #define op1 "op1"
>         #define op2 void
>         #include <foo.h>
> 
> So prototype function arguments in system headers must either not have
> names, or have names in the implementers namespace.
> 
>         --jtc

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:

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

Or even,

#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

Surely all defines should go in user header files or at the very least after the system
includes

Jules