HEADS UP: use proper includes (was: [cvs] bogofilter/src bogoutil.c,1.99,1.100)

Matthias Andree matthias.andree at gmx.de
Thu Feb 5 04:03:19 CET 2004


On Wed, 04 Feb 2004, David Relson wrote:

> Below are two compilations of bogoutil.c.  The one with "-I../gnugetopt"
> complains about getopt.

This is healed by the include path split, see other mail.

> Since config.h has 
> 
> /* Define to 1 if you have the declaration of `getopt', and to 0 if you
> don't.
>    */
> #define HAVE_DECL_GETOPT 1
> 
> /* Define to 1 if you have the `getopt_long' function. */
> #define HAVE_GETOPT_LONG 1
> 
> and common.h includes system.h includes unistd.h, my linux environment
> doesn't need the "-I" option.

Only until you see the long-winded and entangled road the GNU libc takes
trying to be 'smart' (for any negative value of smart...), there are
some local #define hacks into getopt - and -I$(top_srcdir)/gnugetopt
will poison unistd.h! What a bullshit.

> In common.h, should the declarations for optarg, optind, etc have
> "#ifndef _GETOPT_H" or something?  Should a prototype for getopt() be
> included with them ???

No they shouldn't (this has been POSIX syntax for years), any system
that deviates here, triggering "redeclared as different type" errors
deserves to die.

I can only recommend again to install the newest release of Andries E.
Brouwer's man-pages distribution (see previous posts to the list for
URL) and modify MANPATH so the POSIX man pages show up first, overriding
the FSF/GNU libc man pages. That helps portable programming a lot. The
original pages are still available by typing "man 3 getopt" explicitly
(POSIX would then be man 3p whatever).

Cheers,

-- 
Matthias Andree

Encrypt your mail: my GnuPG key ID is 0x052E7D95




More information about the bogofilter-dev mailing list