HEADS UP: use proper includes (was: [cvs] bogofilter/src bogoutil.c,1.99,1.100)
David Relson
relson at osagesoftware.com
Thu Feb 5 03:45:55 CET 2004
On Thu, 5 Feb 2004 03:23:39 +0100
Matthias Andree wrote:
> On Wed, 04 Feb 2004, relson at users.sourceforge.net wrote:
>
> > Update of /cvsroot/bogofilter/bogofilter/src
> > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20908
> >
> > Modified Files:
> > bogoutil.c
> > Log Message:
> > Provide prototype for getopt().
>
> > +#include <getopt.h>
>
> Not that again. :-/
>
> getopt.h is not a system header but a proprietary FSF (GNU) extension.
>
> unistd.h shall contain this prototype according to POSIX 2001:
>
> int getopt(int, char * const [], const char *);
>
> If you want to include a file that is local to leafnode, please use
> #include "getopt.h" - we have that file available and can adjust
> CPPFLAGS accordingly.
>
Matthias,
Below are two compilations of bogoutil.c. The one with "-I../gnugetopt"
complains about getopt.
[relson at osage src]$ gcc -DHAVE_CONFIG_H -I. -I. -I. -I../trio -I..
-I/usr/include -DBOGOFILTER -g -O2 -Wpointer-arith -ggdb -Wall -W
-Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wbad-function-cast
-Wcast-qual -Wcast-align -Wwrite-strings -Waggregate-return
-Wmissing-declarations -Wmissing-format-attribute -Wnested-externs
-fno-common -Wchar-subscripts -Wcomment -Wimplicit -Wsequence-point
-Wreturn-type -Wno-system-headers -Wformat -Wformat=2 -MT bogoutil.o -MD
-MP -MF ".deps/bogoutil.Tpo" -c -o bogoutil.o bogoutil.c --save-temps
bogoutil.c: In function `display_words':
bogoutil.c:270: warning: format not a string literal, argument types not
checked
bogoutil.c:298: warning: format not a string literal, argument types not
checked
bogoutil.c:302: warning: format not a string literal, argument types not
checked
[relson at osage src]$ gcc -DHAVE_CONFIG_H -I. -I. -I. -I../gnugetopt
-I../trio -I.. -I/usr/include -DBOGOFILTER -g -O2 -Wpointer-arith -ggdb
-Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wshadow
-Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings
-Waggregate-return -Wmissing-declarations -Wmissing-format-attribute
-Wnested-externs -fno-common -Wchar-subscripts -Wcomment -Wimplicit
-Wsequence-point -Wreturn-type -Wno-system-headers -Wformat -Wformat=2
-MT bogoutil.o -MD -MP -MF ".deps/bogoutil.Tpo" -c -o bogoutil.o
bogoutil.c --save-temps
bogoutil.c: In function `display_words':
bogoutil.c:270: warning: format not a string literal, argument types not
checked
bogoutil.c:298: warning: format not a string literal, argument types not
checked
bogoutil.c:302: warning: format not a string literal, argument types not
checked
bogoutil.c: In function `process_arglist':
bogoutil.c:422: warning: implicit declaration of function `getopt'
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.
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 ???
More information about the bogofilter-dev
mailing list