Skip to content

Commit

Permalink
check: add -Wpendantic compiler flag to CI builds
Browse files Browse the repository at this point in the history
- Silence compiler warnings in include/grass/vect/dig_defines.h using
compiler #pragma statements.
  • Loading branch information
nilason committed Nov 18, 2023
1 parent c307930 commit e89b575
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build_ubuntu-22.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ fi
# an old version of configure, which issues compiler warnings and
# errors out. This may be removed with upgraded configure.in file.
makecmd="make"
if [[ "$#" -eq 2 ]]; then
makecmd="make CFLAGS='$CFLAGS $2' CXXFLAGS='$CXXFLAGS $2'"
if [[ "$#" -ge 2 ]]; then
ARGS=("$@")
makecmd="make CFLAGS='$CFLAGS ${ARGS[@]:1}' CXXFLAGS='$CXXFLAGS ${ARGS[@]:1}'"
fi

# non-existent variables as an errors
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Get dependencies
run: |
sudo apt-get update -y
Expand Down Expand Up @@ -63,4 +63,6 @@ jobs:
CFLAGS: -std=${{ matrix.c }} -fPIC -Wall -Wextra
# TODO: -pedantic-errors here won't compile
CXXFLAGS: -std=${{ matrix.cpp }} -fPIC -Wall -Wextra
run: .github/workflows/build_ubuntu-22.04.sh $HOME/install -Werror
run: |
.github/workflows/build_ubuntu-22.04.sh $HOME/install \
-isystem/usr/include/gdal -Wpedantic -Werror
7 changes: 4 additions & 3 deletions .github/workflows/macos_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ CONFIGURE_FLAGS="\
--with-readline-libs=${CONDA_PREFIX}/lib
"

export CFLAGS="-O2 -pipe -arch ${CONDA_ARCH} -DGL_SILENCE_DEPRECATION -Wall -Wextra"
export CXXFLAGS="-O2 -pipe -stdlib=libc++ -arch ${CONDA_ARCH} -Wall -Wextra"
export CFLAGS="-O2 -pipe -arch ${CONDA_ARCH} -DGL_SILENCE_DEPRECATION -Wall -Wextra -Wpedantic"
export CXXFLAGS="-O2 -pipe -stdlib=libc++ -arch ${CONDA_ARCH} -Wall -Wextra -Wpedantic"
export CPPFLAGS="-isystem${CONDA_PREFIX}/include"

./configure $CONFIGURE_FLAGS

EXEMPT="-Wno-error=deprecated-non-prototype"
EXEMPT="-Wno-error=deprecated-non-prototype -Wno-error=strict-prototypes"
make -j$(sysctl -n hw.ncpu) CFLAGS="$CFLAGS -Werror $EXEMPT" \
CXXFLAGS="$CXXFLAGS -Werror $EXEMPT"

Expand Down
12 changes: 12 additions & 0 deletions include/grass/vect/dig_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ typedef enum overlay_operator OVERLAY_OPERATOR;
/*! \brief GRASS ASCII vector format - well-known-text format */
#define GV_ASCII_FORMAT_WKT 2

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpedantic"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
/*! \brief Simple feature types
Taken from GDAL/OGR library (ogr/ogr_core.h)
Expand Down Expand Up @@ -252,6 +259,11 @@ typedef enum {
SF_MULTIPOLYGON25D = 0x80000006, /* 2.5D extension as per 99-402 */
SF_GEOMETRYCOLLECTION25D = 0x80000007 /* 2.5D extension as per 99-402 */
} SF_FeatureType;
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

#define HEADSTR 50

Expand Down

0 comments on commit e89b575

Please sign in to comment.