[GRASS-git] [OSGeo/grass] 3089db: Define MIN() and MAX() correctly and exactly once ...

Denis Ovsienko noreply at github.com
Wed Aug 25 07:43:53 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 3089db70b0c2c4fa70480cd141c3ea0941ee9907
      https://github.com/OSGeo/grass/commit/3089db70b0c2c4fa70480cd141c3ea0941ee9907
  Author: Denis Ovsienko <denis at ovsienko.info>
  Date:   2021-08-25 (Wed, 25 Aug 2021)

  Changed paths:
    M display/d.linegraph/main.c
    M imagery/i.segment/region_growing.c
    M include/grass/gis.h
    M lib/btree2/kdtree.c
    M lib/cairodriver/line_width.c
    M lib/cairodriver/raster.c
    M lib/imagery/georef_tps.c
    M lib/raster/fpreclass.c
    M lib/raster/quant.c
    M lib/raster3d/tilewrite.c
    M lib/vector/Vlib/buffer2.c
    M lib/vector/Vlib/dgraph.c
    M lib/vector/Vlib/e_intersect.c
    M lib/vector/dglib/graph.c
    M lib/vector/rtree/rect.c
    M raster/r.buildvrt/proto.h
    M raster/r.external/proto.h
    M raster/r.geomorphon/local_proto.h
    M raster/r.grow.distance/main.c
    M raster/r.in.gdal/main.c
    M raster/r.out.pov/main.c
    M raster/r.proj/bordwalk.c
    M raster/r.stats.zonal/main.c
    M raster/r.surf.contour/contour.h
    M raster/r.surf.fractal/frac.h
    M raster3d/r3.in.ascii/main.c
    M raster3d/r3.in.v5d/main.c
    M raster3d/r3.mask/main.c
    M raster3d/r3.null/main.c
    M raster3d/r3.out.ascii/main.c
    M raster3d/r3.out.v5d/main.c
    M vector/v.buffer/main.c
    M vector/v.cluster/main.c

  Log Message:
  -----------
  Define MIN() and MAX() correctly and exactly once (#1795)

Instead of many .c and .h files defining, undefing and redefining MIN()
and MAX() have <grass/gis.h> (re)define each macro. Besides the obvious
code deduplication, this addresses a number of compiler warnings:

main.c:51: warning: "MIN" redefined
main.c:52: warning: "MAX" redefined
main.c:30: warning: "MIN" redefined
main.c:31: warning: "MAX" redefined
contour.h:10: warning: "MIN" redefined
contour.h:10: warning: "MIN" redefined
contour.h:10: warning: "MIN" redefined
contour.h:10: warning: "MIN" redefined
contour.h:10: warning: "MIN" redefined
frac.h:19: warning: "MAX" redefined
frac.h:19: warning: "MAX" redefined
frac.h:19: warning: "MAX" redefined
frac.h:19: warning: "MAX" redefined

This also addresses another, less apparent problem: macro definitions
that lack sufficient parenthesis around their arguments are a classic
error. For example, this definition evaluates incorrectly when b is a
ternary conditional itself:

 #define MAX(a,b) (a > b ? a : b)

Resolve the name clash in raster/r.stats.zonal/main.c with a prefix and
fixup indentation while at it.




More information about the grass-commit mailing list