[GRASS5] raster category confusion

Glynn Clements glynn at gclements.plus.com
Fri Sep 2 17:56:36 EDT 2005


Markus Neteler wrote:

> > > Entering raw_stats():
> > > raw_stats.c:49
> > >  rastp[i] = rast[i];
> > >  i=0
> > >  rastp[0]= void
> > > 
> > >  raw_stats.c:98, when i is 0, then
> > > *((CELL *) rastp[i]) is 120.
> > > 
> > > Then it prints 120 and so forth.
> > > 
> > > Should I add some G_debug() in raw_stats?
> > 
> > I'd start by examining the pointers rastp[0] and rast[0], and the
> > contents of the buffer to which they point, before entering the
> > "for (col = ..." loop. I.e.:
> > 
> > 	print rast[0]
> > 	print rastp[0]
> > 	print *(CELL*)(rast[0])@50
> 
> The @ is dislike (not sure what it does). This is what I get:

The above are gdb commands. Appending @<n> to a value in a gdb print
statement prints <n> elements.

> GRASS 6.1.cvs (spearfish60):~/grass61/raster/r.stats > cvs diff raw_stats.c
> Index: raw_stats.c
> ===================================================================
> RCS file: /grassrepository/grass6/raster/r.stats/raw_stats.c,v
> retrieving revision 2.1
> diff -u -r2.1 raw_stats.c
> --- raw_stats.c 13 Jul 2005 15:55:40 -0000      2.1
> +++ raw_stats.c 1 Sep 2005 13:10:08 -0000
> @@ -52,6 +52,11 @@
>         if (with_coordinates)
>             G_format_northing (G_row_to_northing(row+.5, &window), nbuf, -1);
> 
> +
> +       G_debug(0, "rast[%d]: %d", rast[i], i);
> +       G_debug(0, "rastp[%d]: %d", rastp[i], i);

The arguments are the wrong way around.

> +       G_debug(0, "*(CELL*)(rast[0]): %d", *(CELL*)(rast[0]));
> +       G_debug(0, "*(CELL*)(rast[%d]): %d", *(CELL*)(rast[i]));
>         for (col = 0; col < ncols; col++)
>         {
>             if (no_nulls || no_nulls_all)
> GRASS 6.1.cvs (spearfish60):~/grass61/raster/r.stats > r.stats -1 one
> D0/0: rast[0]: 1
> D0/0: rastp[0]: 1

These two say that rast[1] == rastp[1] == 0 (i.e. NULL). I would have
expected to see values for rast[0].

>  gcc version 3.4.3 20050227 (Red Hat 3.4.3-22.1)
> 
> I just see that the damn optimization creeped in again.
> 
> When I do
> 
> CFLAGS="-g -Wall" ./configure ...
> checking host system type... i686-pc-linux-gnu
> checking for gcc... gcc
> checking whether the C compiler (gcc -g -Wall ) works... yes
> checking whether the C compiler (gcc -g -Wall ) is a cross-compiler... no
> ...
>  C compiler:                  gcc -g -Wall
>  C++ compiler:                c++ -g -O2
> ...
> 
> But:
> grep CFLAGS_OPTIMIZE ~/grass61/include/Make/Platform.make
> CFLAGS_OPTIMIZE     = -O2
> 
> I have to manually fix that. Seems to be evil in aclocal.m4
> around line 756:

Right. Both CFLAGS_OPTIMIZE and CFLAGS_WARNING are bogus. Any compiler
switches which aren't essential (e.g. include directories) should be
left up to the user.

The simplest solution is to remove them from include/Make/*.make[.in].

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




More information about the grass-dev mailing list