[GRASS5] r.flow: strange compile error M_PI

Markus Neteler neteler at itc.it
Wed Jun 22 23:22:10 EDT 2005


On Wed, Jun 22, 2005 at 08:03:22PM -0700, Brad Douglas wrote:
> On Thu, 2005-06-23 at 04:25 +0200, Markus Neteler wrote:
> > On Wed, Jun 22, 2005 at 07:04:55PM -0700, Brad Douglas wrote:
> > > On Thu, 2005-06-23 at 00:12 +0200, Markus Neteler wrote:
> > > > Hi,
> > > > 
> > > > after an update of the Linux OS, I am no longer able to
> > > > compile r.flow:
> > > > 
> > > > thuille:r.flow[281.25] make
> > > > gcc -I/hardmnt/thuille0/ssi/software/cvsgrass61/include -I/hardmnt/thuille0/ssi/software/cvsgrass61/dist.i686-pc-linux-gnu/include/grass  -g -Wall -ansi  -Wall -Wconversion -Wno-implicit-int   -I/usr/local/include     -DPACKAGE=\""grassmods"\"  -I/hardmnt/thuille0/ssi/software/cvsgrass61/include -I/hardmnt/thuille0/ssi/software/cvsgrass61/dist.i686-pc-linux-gnu/include/grass \
> > > >         -o OBJ.i686-pc-linux-gnu/aspect.o -c aspect.c
> > > > aspect.c: In function `aspect_fly':
> > > > aspect.c:50: error: `M_PI' undeclared (first use in this function)
> > > > aspect.c:50: error: (Each undeclared identifier is reported only once
> > > > aspect.c:50: error: for each function it appears in.)
> > > > make: *** [OBJ.i686-pc-linux-gnu/aspect.o] Error 1
> > > > 
> > > > thuille:r.flow[282.26] cat /etc/issue
> > > > Red Hat Enterprise Linux WS release 4 (Nahant Update 1)
> > > > Kernel \r on an \m
> > > > 
> > > > It should be in math.h, right?
> > > > How to debug such things?
> > > 
> > > Yes, it should be in <math.h>, but it's not defined on all systems. I
> > > don't understand it being missing from your system, either.
> > 
> > Sorry, forgot to post that. Yes, it is defined:
> > 
> > grep M_PI /usr/include/math.h
> > # define M_PI           3.14159265358979323846  /* pi */
> > # define M_PI_2         1.57079632679489661923  /* pi/2 */
> > # define M_PI_4         0.78539816339744830962  /* pi/4 */
> > # define M_PIl          3.1415926535897932384626433832795029L  /* pi */
> > # define M_PI_2l        1.5707963267948966192313216916397514L  /* pi/2 */
> > # define M_PI_4l        0.7853981633974483096156608458198757L  /* pi/4 */
> > 
> >  
> > > Generally, I add the following to the source that uses it:
> > > 
> > > #ifndef M_PI
> > > #define M_PI 3.14...
> > > #endif
> 
> I believe I have found the culprit.  M_PI is not defined when specifying
> the -ansi compiler option.

Ah! Thanks, Brad. You suggested ifndef statement is now in the
code (with copy-paste of pi from /usr/include/math.h).

The problem seems to be solved.

Markus




More information about the grass-dev mailing list