ossimlabs / ossim

Core OSSIM (Open Source Software Image Map) package including C++ code for OSSIM library, command-line applications, tests, and build system
MIT License
300 stars 142 forks source link

Fixed compliation error on Mac OS Sierra (XCode 8.3) #199

Closed nickrobison closed 6 years ago

nickrobison commented 6 years ago

While attempting to build the latest version of ossim for inclusion in homebrew-osgeo4mac, we ran into the following error while building on Travis in Mac OS Sierra (Xcode 8.3.3.)

Scanning dependencies of target ossim
/Applications/Xcode8.3.3.app/Contents/Developer/usr/bin/make -f src/CMakeFiles/ossim.dir/build.make src/CMakeFiles/ossim.dir/build
[  0%] Building CXX object src/CMakeFiles/ossim.dir/init/JsonConfig.cpp.o
cd /Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/build/src && /Applications/Xcode8.3.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -Dossim_EXPORTS -I/Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/include -I/Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/build/include -I/usr/local/include -I/usr/local/include/freetype2  -std=c++11 -DNDEBUG -fPIC    -fPIC -std=c++11 -o CMakeFiles/ossim.dir/init/JsonConfig.cpp.o -c /Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/src/init/JsonConfig.cpp
[  0%] Building CXX object src/CMakeFiles/ossim.dir/init/ossimInit.cpp.o
cd /Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/build/src && /Applications/Xcode8.3.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -Dossim_EXPORTS -I/Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/include -I/Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/build/include -I/usr/local/include -I/usr/local/include/freetype2  -std=c++11 -DNDEBUG -fPIC    -fPIC -std=c++11 -o CMakeFiles/ossim.dir/init/ossimInit.cpp.o -c /Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/src/init/ossimInit.cpp
In file included from /Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/src/init/ossimInit.cpp:32:
In file included from /Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/include/ossim/base/ossimGeoidManager.h:19:
/Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/include/ossim/base/ossimRefPtr.h:103:76: error: unknown type name
      'nullptr_t'; did you mean 'std::nullptr_t'?
template<typename _Tp> inline bool operator==(const ossimRefPtr<_Tp>& __a, nullptr_t) noexcept
                                                                           ^~~~~~~~~
                                                                           std::nullptr_t
/Applications/Xcode8.3.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef:97:31: note:
      'std::nullptr_t' declared here
    typedef decltype(nullptr) nullptr_t;
                              ^
In file included from /Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/src/init/ossimInit.cpp:32:
In file included from /Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/include/ossim/base/ossimGeoidManager.h:19:
/Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/include/ossim/base/ossimRefPtr.h:106:47: error: C++ requires a type
      specifier for all declarations
template<typename _Tp> inline bool operator==(nullptr_t, const ossimRefPtr<_Tp>& __a) noexcept
                                              ^
/Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/include/ossim/base/ossimRefPtr.h:113:76: error: unknown type name
      'nullptr_t'; did you mean 'std::nullptr_t'?
template<typename _Tp> inline bool operator!=(const ossimRefPtr<_Tp>& __a, nullptr_t) noexcept
                                                                           ^~~~~~~~~
                                                                           std::nullptr_t
/Applications/Xcode8.3.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef:97:31: note:
      'std::nullptr_t' declared here
    typedef decltype(nullptr) nullptr_t;
                              ^
In file included from /Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/src/init/ossimInit.cpp:32:
In file included from /Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/include/ossim/base/ossimGeoidManager.h:19:
/Users/nickrobison/Developer/external/ossim-Gasparilla-2.3.1/include/ossim/base/ossimRefPtr.h:116:47: error: C++ requires a type
      specifier for all declarations
template<typename _Tp> inline bool operator!=(nullptr_t, const ossimRefPtr<_Tp>& __a) noexcept
                                              ^
4 errors generated.
make[2]: *** [src/CMakeFiles/ossim.dir/init/ossimInit.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/ossim.dir/all] Error 2
make: *** [all] Error 2

This patch adds the std namespace to nullptr_t references and includes the <cstddef> header, which resolves the compilation error. I've tested on both Mac OS Sierra and High Sierra, using the latest Xcode 9.3

Thanks for the great work on an excellent project!

gpotts commented 6 years ago

Thank you for the patch. We are in a code freeze for the next day or so..I'll merge it in after the code freeze.

gpotts commented 6 years ago

I have merged the code and will test on our build systems. Thank you!