[GRASS5] RE: [winGRASS] GRASS 5.0.0 released!

Eric G. Miller egm2 at jps.net
Mon Sep 9 22:29:11 EDT 2002


On Mon, Sep 09, 2002 at 05:11:50PM +0100, Glynn Clements wrote:
> 
> Malcolm Blue wrote:
> 
> > > Hmm. GNU libc's math.h also declares "round", but only if 
> > > __USE_ISOC9X is defined. I wonder if Cygwin's gcc defaults to 
> > > C9X rather than C89.
> > >
> > 
> > It appears to. Round is declared after:
> > 
> > #ifndef __STRICT_ANSI__
> > 
> > /* ISO C99 types and macros. */
> > 
> > > IIRC, the most recent versions of gcc (3.x, maybe some later 
> > > 2.9x) have an option to select the dialect (C89/C9X), so it 
> > > may be possible to get around this problem by setting CFLAGS 
> > > prior to running "configure".
> > > 
> > 
> > You are right, I could have defined __STRICT_ANSI__ to avoid this error.
> 
> Or used "gcc -ansi ...", which causes that macro to be defined. 
> However, I suspect that either approach would be a bad idea; much of
> GRASS is not ANSI conformant.
> 
> That does at least tell me that the code has to be changed; it can't
> be solved through compiler switches.

If checking for which C standard is in operation, one can check for
__STDC__VERSION__ which should be defined for any C implementation
conforming to iso9899:199409 (i.e. >= C94 amendment):

#if defined __STDC__VERSION__
# if __STDC__VERSION__ + 0 < 199900L
#   define round(x) floor((x)+0.5)
# endif
#else
#    define round(x) floor((x)+0.5)
#endif

Or something... Not sure when round() was introduced; think C99.  Might
also be POSIX or XOPEN preceeding C99...

Borderline functions that may be supported in some environments, but
not others should be handled via config and compatibility routines.
It's probably easier to test for them in ./configure as well...

rint() is probably preferrable to round() which normally should round
to nearest rather than away from zero as round() does.  But, it is
C99...

-- 
begin 664 .signature
M<F5L;&E-("Y'(&-I<D4@/G1E;BYS<&I`,FUG93P)"`@("`@("`@("`@("`@(
M"`@("`@("`@("`@("`@("`A%<FEC($<N($UI;&QE<B`\96=M,D!J<',N;F5T
"/@H`
`
end




More information about the grass-dev mailing list