TopoToolbox / libtopotoolbox

A C library for the analysis of digital elevation models.
https://topotoolbox.github.io/libtopotoolbox/
GNU General Public License v3.0
0 stars 3 forks source link

Set C/C++ standards and add more aggressive compiler warnings #19

Closed wkearn closed 3 months ago

wkearn commented 3 months ago

This sets the C++ standard to C++11 and the C standard to C99.

Compiler warnings "/W4" and "-Wall -Wextra -Wpedantic" are used for MSVC and GCC/Clang, respectively. The unused parameter warning is turned off for all compilers now because it warns about argc, argv not being used in main functions.

Compiler warnings are treated as errors using CMake's CMAKE_COMPILE_WARNING_AS_ERROR variable. This can be turned off on the command line with cmake --compile-no-warning-as-error if necessary. For now, it is useful to ensure CI fails when compiler warnings are emitted.

test/fillsinks.cpp is modified to ensure that it builds with the new compiler settings. This requires removing a hexadecimal floating point literal, which is added in C++17 and modifying some of the types of variables passed to the hash function to comply with its interface.