[GRASS-dev] compilation issues with lex

Glynn Clements glynn at gclements.plus.com
Wed Aug 16 21:31:51 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.

GRASS relies upon various POSIX functions; if you use -ansi or
-pedantic, you also need -D_POSIX_SOURCE (you may require some others,
e.g. _SVID_SOURCE and/or _BSD_SOURCE; ideally, those two shouldn't be
necessary, but we can't do without _POSIX_SOURCE).

For r.mapcalc, we could get around this specific issue by using
G_store() instead. lib/db/sqlp doesn't currently use libgis, so using
G_store() would add a new dependency.

However, there may be other non-ANSI functions which are similarly
affected. When -ansi or -pedantic are used, ANSI headers such as
<string.h> don't declare any non-ANSI functions unless specifically
enabled using the appropriate macro from <features.h>.

> Help appreciated since I am not familiar with lex.

This isn't specifically a lex issue; the use of strdup() is in C code
which lex copies verbatim to the output file (lex.yy.c).

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




More information about the grass-dev mailing list