[GRASS-dev] compilation issues with lex

Glynn Clements glynn at gclements.plus.com
Thu Aug 17 08:05:28 EDT 2006


Markus Neteler wrote:

> > > I have started to compile the well known software on
> > > the new geodata blade of OSGeo nad encountered a few
> > > problems:
> > > 
> > > cd lib/db/sqlp
> > > make
> > > gcc -I/mnt/home/neteler/software/grass6_cvs/dist.i686-pc-linux-gnu/include  -g -Wall -pedantic -Werror-implicit-function-declaration -fno-common    -fPIC    -DPACKAGE=\""grasslibs"\"     -DPACKAGE=\""grasslibs"\"  -I/mnt/home/neteler/software/grass6_cvs/dist.i686-pc-linux-gnu/include \
> > >         -o OBJ.i686-pc-linux-gnu/lex.yy.o -c lex.yy.c
> > > lex.l: In function 'yylex':
> > > lex.l:76: error: implicit declaration of function 'strdup'
> > 
> > > cd raster/r.mapcalc
> > > [neteler at xblade11-2 r.mapcalc]$ make
> > > gcc -I/mnt/home/neteler/software/grass6_cvs/dist.i686-pc-linux-gnu/include  -g -Wall -pedantic -Werror-implicit-function-declaration -fno-common        -DPACKAGE=\""grassmods"\"  -I/mnt/home/neteler/software/grass6_cvs/dist.i686-pc-linux-gnu/include \
> > >         -o OBJ.i686-pc-linux-gnu/lex.yy.o -c lex.yy.c
> > > mapcalc.l: In function 'yylex':
> > > mapcalc.l:134: error: implicit declaration of function 'strdup'
> > 
> > strdup() is defined in <string.h>, but it isn't ANSI and you're using
> > -pedantic.
> 
> The problem remains when I don't use -pedantic.
> 
> I assume that -Werror-implicit-function-declaration is the problem
> now:
> 
> MYCFLAGS="-g -Wall -Werror-implicit-function-declaration -fno-common"
> MYCXXFLAGS="-g -Wall"

It shouldn't be; with the default feature macros (i.e. _GNU_SOURCE),
including <string.h> should declare strdup().

OTOH, I'm a bit confused by:

lex.l:76: warning: incompatible implicit declaration of built-in function 'strdup'

which suggests that strdup() is a built-in function. strdup() isn't a
particularly obvious choice for a built-in function; most built-in
functions tend to be something which can be implemented in a handful
of CPU instructions, e.g. memset, memcpy, etc.

I suggest looking at the logic surrounding the declaration of strdup()
in string.h, in case that provides any clues.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list