SGL-UT / gnsstk

The goal of the gnsstk project is to provide an open source library to the satellite navigation community--to free researchers to focus on research, not lower level coding.
Other
113 stars 50 forks source link

Return type warning treated as error - compilation fails on Linux #20

Open coezmaden opened 12 months ago

coezmaden commented 12 months ago

Due to the setting of -Werror=return-type in the compiler flags below:

https://github.com/SGL-UT/gnsstk/blob/c4b1b21124a093a1ee8f19c09b9d258d4a6d12aa/BuildSetup.cmake#L54

the project won't compile on my Linux using Cmake due to no return statement placed before the bracket here:

https://github.com/SGL-UT/gnsstk/blob/c4b1b21124a093a1ee8f19c09b9d258d4a6d12aa/core/lib/GNSSCore/RefFrameRlz.cpp#L177

Here is the warning treated as error that gcc 7.5.0 issues:

[ 30%] Building CXX object CMakeFiles/gnsstk.dir/core/lib/GNSSCore/SatMetaDataStore.cpp.o
/home/coezmaden/Repositories/gnsstk/core/lib/GNSSCore/RefFrameRlz.cpp: In function ‘gnsstk::RefFrameRlz gnsstk::getRefFrameRlz(gnsstk::RefFrameSys, const gnsstk::CommonTime&)’:
/home/coezmaden/Repositories/gnsstk/core/lib/GNSSCore/RefFrameRlz.cpp:177:4: error: control reaches end of non-void function [-Werror=return-type]
    }
    ^

Can be a potential easy fix by adding a return of an unknown reference frame RefFrameRlz::Unknown as I have done in my fork: https://github.com/SGL-UT/gnsstk/commit/3f332d5362a9f98d238f11c7c517549b11a2e3f3 Should be tested for unwanted changes to the logic of the function.

coezmaden commented 11 months ago

A fix for Linux users who just want to get on with their lives: Set an additional cmake flag -DCMAKE_CXX_FLAGS=\'-w\'.

Extract from the gcc man page:

-w Inhibit all warning messages.