error: ISO C++17 does not allow 'register' storage class specifier
tianjiaoding opened this issue · comments
Hi Daniel,
It seems that my MacOS can not compile the project successfully, with complaints that seem to relate C++17 and compiler options. Maybe the project is not intended to be compiled on MacOS, but since the readme mentions C++17, I am just wondering if you happen to have ideas on what is going on here:
Scanning dependencies of target GraphCutRANSAC Scanning dependencies of target pygcransac [ 7%] Building CXX object CMakeFiles/GraphCutRANSAC.dir/src/pygcransac/include/GCoptimization.cpp.o In file included from /Users/richardding/Dropbox/graph-cut-ransac/src/pygcransac/include/GCoptimization.cpp:4: In file included from /Users/richardding/Dropbox/graph-cut-ransac/src/pygcransac/include/GCoptimization.h:109: /Users/richardding/Dropbox/graph-cut-ransac/src/pygcransac/include/energy.h:262:2: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister] register Value pi = (E000 + E011 + E101 + E110) - (E100 + E010 + E001 + E111); ^~~~~~~~~ /Users/richardding/Dropbox/graph-cut-ransac/src/pygcransac/include/energy.h:263:2: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister] register Value delta; ^~~~~~~~~ /Users/richardding/Dropbox/graph-cut-ransac/src/pygcransac/include/energy.h:264:2: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister] register Var u; ^~~~~~~~~
I am running cmake 3.15.5, with gcc configuration
gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1 Apple LLVM version 10.0.1 (clang-1001.0.46.4) Target: x86_64-apple-darwin18.2.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Any insights would be appreciated!
I resolved this problem. My first attempt is to use C++14, but the use of C++17 feature std::clamp
prevents me from doing so. Then I searched to see what is register
. It seems from this page that this is similar to auto
. And since the type has already been specified (e.g., type Value
), it can be removed safely without semantically changing anything.
I am happy you solved it!
This was an issue earlier as well: #13
Aha, I forgot to check the issues that are closed. Thanks for your reply. Anyhow, I proposed a pull request #24 addressing this issue. Hope this will save time for others.