nifpp icon indicating copy to clipboard operation
nifpp copied to clipboard

example compilation fails on recent osx

Open Cloven opened this issue 8 years ago • 2 comments

Not exactly sure what's going on here as my C++ template-fu is not strong, but:

erlang 19.0 Darwin spatula 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64 Apple LLVM version 7.3.0 (clang-703.0.31) Target: x86_64-apple-darwin15.4.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

$ make c++ -g -O3 -ansi -pedantic -Wall -Wextra -I../ -I/usr/local/lib/erlang/erts-8.0/include -fPIC -std=c++11 -c nifpptest.cpp nifpptest.cpp:419:40: warning: unused parameter 'priv' [-Wunused-parameter] static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info) ^ nifpptest.cpp:419:59: warning: unused parameter 'load_info' [-Wunused-parameter] static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info) ^ nifpptest.cpp:427:52: warning: unused parameter 'argc' [-Wunused-parameter] static ERL_NIF_TERM invoke_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) ^ nifpptest.cpp:439:49: warning: unused parameter 'argc' [-Wunused-parameter] static ERL_NIF_TERM foo_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) ^ nifpptest.cpp:449:49: warning: unused parameter 'argc' [-Wunused-parameter] static ERL_NIF_TERM bar_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) ^ nifpptest.cpp:460:33: warning: missing field 'flags' initializer [-Wmissing-field-initializers] {"invoke_nif", 1, invoke_nif}, ^ In file included from nifpptest.cpp:1: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iostream:38: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:216: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__locale:18: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/mutex:177: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:659:21: error: invalid operands to binary expression ('const nifpp::TERM' and 'const nifpp::TERM') {return __x == __y;} ~~~ ^ ~~~ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:1759:21: note: in instantiation of member function 'std::__1::equal_tonifpp::TERM::operator()' requested here if (key_eq()(__nd->_value, __x)) ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:1724:12: note: in instantiation of function template specialization 'std::__1::__hash_table<nifpp::TERM, std::__1::hashnifpp::TERM, std::__1::equal_tonifpp::TERM, std::__1::allocatornifpp::TERM >::__insert_unique_value<const nifpp::TERM &>' requested here return __insert_unique_value(__x); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_set:495:26: note: in instantiation of member function 'std::__1::__hash_table<nifpp::TERM, std::__1::hashnifpp::TERM, std::__1::equal_tonifpp::TERM, std::__1::allocatornifpp::TERM >::__insert_unique' requested here {return _table.__insert_unique(__x);} ^ ../nifpp.h:991:59: note: in instantiation of member function 'std::__1::unordered_set<nifpp::TERM, std::__1::hashnifpp::TERM, std::__1::equal_tonifpp::TERM, std::__1::allocatornifpp::TERM >::insert' requested here return list_for_each<T>(env, term, [&var](T item){var.insert(item);}); ^ ../nifpp.h:1104:9: note: in instantiation of function template specialization 'nifpp::getnifpp::TERM' requested here if(!get(env, term, t)) ^ nifpptest.cpp:40:5: note: in instantiation of function template specialization 'nifpp::get_throws<std::__1::unordered_set<nifpp::TERM, std::__1::hashnifpp::TERM, std::__1::equal_tonifpp::TERM, std::__1::allocatornifpp::TERM > >' requested here get_throws(env, term, container); ^ nifpptest.cpp:282:39: note: in instantiation of function template specialization 'set2_test<std::__1::unordered_set<nifpp::TERM, std::__1::hashnifpp::TERM, std::__1::equal_tonifpp::TERM, std::__1::allocatornifpp::TERM > >' requested here else if(cmd=="list2bf") { return set2_teststd::unordered_set<nifpp::TERM >(env, cmddata); } ^ In file included from nifpptest.cpp:11: In file included from ../nifpp.h:42: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_set:323: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:1993:32: error: no matching function for call to object of type 'key_equal' (aka 'std::__1::__unordered_map_equal<nifpp::TERM, std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM>, std::__1::equal_tonifpp::TERM, true>') key_eq()(__cp->_value, __np->_next->_value); ^~~~~~~~ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:1939:9: note: in instantiation of member function 'std::__1::__hash_table<std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM>, std::__1::__unordered_map_hasher<nifpp::TERM, std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM>, std::__1::hashnifpp::TERM, true>, std::__1::__unordered_map_equal<nifpp::TERM, std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM>, std::__1::equal_tonifpp::TERM, true>, std::__1::allocator<std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM> > >::__rehash' requested here __rehash(__n); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:1587:13: note: in instantiation of member function 'std::__1::__hash_table<std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM>, std::__1::__unordered_map_hasher<nifpp::TERM, std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM>, std::__1::hashnifpp::TERM, true>, std::__1::__unordered_map_equal<nifpp::TERM, std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM>, std::__1::equal_tonifpp::TERM, true>, std::__1::allocator<std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM> > >::rehash' requested here rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc), ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:1536:41: note: in instantiation of member function 'std::__1::__hash_table<std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM>, std::__1::__unordered_map_hasher<nifpp::TERM, std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM>, std::__1::hashnifpp::TERM, true>, std::__1::__unordered_map_equal<nifpp::TERM, std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM>, std::__1::equal_tonifpp::TERM, true>, std::__1::allocator<std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM> > >::__node_insert_unique' requested here pair<iterator, bool> __r = _table.__node_insert_unique(__h.get()); ^ nifpptest.cpp:76:9: note: in instantiation of member function 'std::__1::unordered_map<nifpp::TERM, nifpp::TERM, std::__1::hashnifpp::TERM, std::__1::equal_tonifpp::TERM, std::__1::allocator<std::__1::pair<const nifpp::TERM, nifpp::TERM> > >::operator[]' requested here outmap[i->second] = i->first; ^ nifpptest.cpp:310:40: note: in instantiation of function template specialization 'umapflip_test<nifpp::TERM, nifpp::TERM>' requested here else if(cmd=="mapflipab") { return umapflip_test<nifpp::TERM, nifpp::TERM>(env, cmddata); } ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:476:10: note: candidate function not viable: no known conversion from 'value_type' (aka 'std::__1::__hash_value_type<nifpp::TERM, nifpp::TERM>') to 'const nifpp::TERM' for 1st argument bool operator()(const _Key& __x, const _Cp& __y) const ^ 6 warnings and 2 errors generated. make: *** [nifpptest.o] Error 1

Cloven avatar Aug 16 '16 04:08 Cloven

I'm seeing similar errors with gcc on linux, interesting.

std::unordered_map is testing equality of nifpp::TERM which is not available. I'm not sure what changed to make this not work. And to be clear, using a term value as a map key has problems and is not a good idea for production code.

I've disabled the non-compiling tests in branch termequal. This causes some tests to fail at runtime, but at least it gets thing running until they can be fixed properly.

goertzenator avatar Aug 16 '16 12:08 goertzenator

Actual problem has been fixed in master. Please let me know if that fixes it for you too.

goertzenator avatar Aug 16 '16 13:08 goertzenator