Xcode 8: C++11 compilation failure

Hello. I'm having a problem trying to compile some code from the command line. Long story short, the project uses promise<> from the future library. Here's what I'm seeing when I try to compile the file, which compiles just fine under Xcode 7.3.1. I'm assuming this is an Xcode bug, as something seems to have tripped up the future file and caused the _LIBCPP_AVAILABILITY_FUTURE macro to not be empty and instead equal _LIBCPP_AVAILABILITY_FUTURE_ERROR.


Thanks.


g++ -Icryptopp -Imdb -IBlockDataManager/fcgi -DUSE_CRYPTOPP -D__STDC_LIMIT_MACROS -I/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/include/python2.7 -std=c++11 -stdlib=libc++ -O2 -pipe -fPIC -c BlockUtils.cpp
In file included from BlockUtils.cpp:17:
In file included from ./BlockUtils.h:39:
In file included from ./BDM_supportClasses.h:22:
./ThreadSafeClasses.h:251:26: error: 'promise<bool>' is unavailable: introduced in macOS 10.8
auto newprom = new promise<bool>();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<bool>' has been explicitly marked
unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
In file included from BlockUtils.cpp:17:
In file included from ./BlockUtils.h:39:
In file included from ./BDM_supportClasses.h:22:
./ThreadSafeClasses.h:276:26: error: 'promise<bool>' is unavailable: introduced in macOS 10.8
auto newprom = new promise<bool>();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<bool>' has been explicitly marked
unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
In file included from BlockUtils.cpp:17:
In file included from ./BlockUtils.h:39:
In file included from ./BDM_supportClasses.h:22:
./ThreadSafeClasses.h:291:23: error: 'promise<bool>' is unavailable: introduced in macOS 10.8
auto promptr = (promise<bool>*)promPtr_.load();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<bool>' has been explicitly marked
unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
In file included from BlockUtils.cpp:17:
In file included from ./BlockUtils.h:39:
In file included from ./BDM_supportClasses.h:22:
./ThreadSafeClasses.h:863:20: error: 'future_error' is unavailable: introduced in macOS 10.8
catch (future_error&)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:502:63: note: 'future_error' has been explicitly marked
unavailable here
class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_FUTURE_ERROR future_error
^
In file included from BlockUtils.cpp:17:
In file included from ./BlockUtils.h:39:
In file included from ./BDM_supportClasses.h:23:
./BitcoinP2p.h:464:15: error: 'promise<bool>' is unavailable: introduced in macOS 10.8
unique_ptr<promise<bool>> connectedPromise_ = nullptr;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<bool>' has been explicitly marked
unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
In file included from BlockUtils.cpp:17:
In file included from ./BlockUtils.h:39:
In file included from ./BDM_supportClasses.h:23:
./BitcoinP2p.h:465:15: error: 'promise<bool>' is unavailable: introduced in macOS 10.8
unique_ptr<promise<bool>> verackPromise_ = nullptr;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<bool>' has been explicitly marked
unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
In file included from BlockUtils.cpp:17:
In file included from ./BlockUtils.h:39:
In file included from ./BDM_supportClasses.h:23:
./BitcoinP2p.h:481:4: error: 'future<bool>' is unavailable: introduced in macOS 10.8
future<bool> shutdownFuture_;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1074:57: note: 'future<bool>' has been explicitly marked
unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE future
^
In file included from BlockUtils.cpp:17:
In file included from ./BlockUtils.h:39:
In file included from ./BDM_supportClasses.h:23:
./BitcoinP2p.h:487:18: error: 'promise<bool>' is unavailable: introduced in macOS 10.8
shared_ptr<promise<bool>> promise_;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<bool>' has been explicitly marked
unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
In file included from BlockUtils.cpp:17:
In file included from ./BlockUtils.h:39:
./BDM_supportClasses.h:388:18: error: 'promise<bool>' is unavailable: introduced in macOS 10.8
shared_ptr<promise<bool>> finishedPromise_ = nullptr;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<bool>' has been explicitly marked
unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
In file included from BlockUtils.cpp:21:
./BlockchainScanner.h:42:4: error: 'promise<bool>' is unavailable: introduced in macOS 10.8
promise<bool> scanUtxosPromise;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<bool>' has been explicitly marked
unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
BlockUtils.cpp:1474:12: warning: enumeration value 'Reset_SSH' not handled in switch [-Wswitch]
switch (mode)
^
BlockUtils.cpp:1583:37: error: 'promise<bool>' is unavailable: introduced in macOS 10.8
auto waitOnPromise = make_shared<promise<bool>>();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<bool>' has been explicitly marked
unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1422:1: error: 'promise<std::__1::shared_ptr<Payload> >' is
unavailable: introduced in macOS 10.8
promise<_Rp>::promise()
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2142:49: note: in instantiation of member function
'std::__1::promise<std::__1::shared_ptr<Payload> >::promise' requested here
: _T1(_VSTD::forward<_T1_param>(__t1)), __second_() {}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2411:11: note: in instantiation of member function
'std::__1::__libcpp_compressed_pair_imp<std::__1::allocator<std::__1::promise<std::__1::shared_ptr<Payload> > >, std::__1::promise<std::__1::shared_ptr<Payload> >,
1>::__libcpp_compressed_pair_imp' requested here
: base(_VSTD::forward<_T1_param>(__t1)) {}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3795:12: note: in instantiation of member function
'std::__1::__compressed_pair<std::__1::allocator<std::__1::promise<std::__1::shared_ptr<Payload> > >, std::__1::promise<std::__1::shared_ptr<Payload> >
>::__compressed_pair' requested here
: __data_(_VSTD::move(__a)) {}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4411:26: note: in instantiation of member function
'std::__1::__shared_ptr_emplace<std::__1::promise<std::__1::shared_ptr<Payload> >, std::__1::allocator<std::__1::promise<std::__1::shared_ptr<Payload> > >
>::__shared_ptr_emplace' requested here
::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4775:29: note: in instantiation of function template
specialization 'std::__1::shared_ptr<std::__1::promise<std::__1::shared_ptr<Payload> > >::make_shared<>' requested here
return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...);
^
./BitcoinP2p.h:430:15: note: in instantiation of function template specialization 'std::__1::make_shared<std::__1::promise<std::__1::shared_ptr<Payload> >>' requested here
prom_ = make_shared<promise<shared_ptr<Payload>>>();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<std::__1::shared_ptr<Payload> >' has
been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:632:1: error:
'__assoc_state<std::__1::shared_ptr<Payload> >' is unavailable: introduced in macOS 10.8
__assoc_state<_Rp>::__on_zero_shared() _NOEXCEPT
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1423:20: note: in instantiation of member function
'std::__1::__assoc_state<std::__1::shared_ptr<Payload> >::__on_zero_shared' requested here
: __state_(new __assoc_state<_Rp>)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2142:49: note: in instantiation of member function
'std::__1::promise<std::__1::shared_ptr<Payload> >::promise' requested here
: _T1(_VSTD::forward<_T1_param>(__t1)), __second_() {}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2411:11: note: in instantiation of member function
'std::__1::__libcpp_compressed_pair_imp<std::__1::allocator<std::__1::promise<std::__1::shared_ptr<Payload> > >, std::__1::promise<std::__1::shared_ptr<Payload> >,
1>::__libcpp_compressed_pair_imp' requested here
: base(_VSTD::forward<_T1_param>(__t1)) {}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3795:12: note: in instantiation of member function
'std::__1::__compressed_pair<std::__1::allocator<std::__1::promise<std::__1::shared_ptr<Payload> > >, std::__1::promise<std::__1::shared_ptr<Payload> >
>::__compressed_pair' requested here
: __data_(_VSTD::move(__a)) {}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4411:26: note: in instantiation of member function
'std::__1::__shared_ptr_emplace<std::__1::promise<std::__1::shared_ptr<Payload> >, std::__1::allocator<std::__1::promise<std::__1::shared_ptr<Payload> > >
>::__shared_ptr_emplace' requested here
::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4775:29: note: in instantiation of function template
specialization 'std::__1::shared_ptr<std::__1::promise<std::__1::shared_ptr<Payload> > >::make_shared<>' requested here
return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...);
^
./BitcoinP2p.h:430:15: note: in instantiation of function template specialization 'std::__1::make_shared<std::__1::promise<std::__1::shared_ptr<Payload> >>' requested here
prom_ = make_shared<promise<shared_ptr<Payload>>>();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:601:35: note:
'__assoc_state<std::__1::shared_ptr<Payload> >' has been explicitly marked unavailable here
class _LIBCPP_AVAILABILITY_FUTURE __assoc_state
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1441:1: error: 'promise<std::__1::shared_ptr<Payload> >' is
unavailable: introduced in macOS 10.8
promise<_Rp>::~promise()
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2029:7: note: in instantiation of member function
'std::__1::promise<std::__1::shared_ptr<Payload> >::~promise' requested here
class __libcpp_compressed_pair_imp;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4411:26: note: in instantiation of member function
'std::__1::__shared_ptr_emplace<std::__1::promise<std::__1::shared_ptr<Payload> >, std::__1::allocator<std::__1::promise<std::__1::shared_ptr<Payload> > >
>::__shared_ptr_emplace' requested here
::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4775:29: note: in instantiation of function template
specialization 'std::__1::shared_ptr<std::__1::promise<std::__1::shared_ptr<Payload> > >::make_shared<>' requested here
return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...);
^
./BitcoinP2p.h:430:15: note: in instantiation of function template specialization 'std::__1::make_shared<std::__1::promise<std::__1::shared_ptr<Payload> >>' requested here
prom_ = make_shared<promise<shared_ptr<Payload>>>();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<std::__1::shared_ptr<Payload> >' has
been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1455:1: error: 'promise<std::__1::shared_ptr<Payload> >' is
unavailable: introduced in macOS 10.8
promise<_Rp>::get_future()
^
./BitcoinP2p.h:431:21: note: in instantiation of member function 'std::__1::promise<std::__1::shared_ptr<Payload> >::get_future' requested here
fut_ = prom_->get_future();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<std::__1::shared_ptr<Payload> >' has
been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1145:1: error: 'future<std::__1::shared_ptr<Payload> >' is
unavailable: introduced in macOS 10.8
future<_Rp>::future(__assoc_state<_Rp>* __state)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1461:12: note: in instantiation of member function
'std::__1::future<std::__1::shared_ptr<Payload> >::future' requested here
return future<_Rp>(__state_);
^
./BitcoinP2p.h:431:21: note: in instantiation of member function 'std::__1::promise<std::__1::shared_ptr<Payload> >::get_future' requested here
fut_ = prom_->get_future();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1074:57: note: 'future<std::__1::shared_ptr<Payload> >' has
been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE future
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1162:1: error: 'future<std::__1::shared_ptr<Payload> >' is
unavailable: introduced in macOS 10.8
future<_Rp>::~future()
^
./BitcoinP2p.h:431:14: note: in instantiation of member function 'std::__1::future<std::__1::shared_ptr<Payload> >::~future' requested here
fut_ = prom_->get_future();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1074:57: note: 'future<std::__1::shared_ptr<Payload> >' has
been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE future
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1441:1: error: 'promise<InvEntry>' is unavailable:
introduced in macOS 10.8
promise<_Rp>::~promise()
^
./ThreadSafeClasses.h:335:23: note: in instantiation of member function 'std::__1::promise<InvEntry>::~promise' requested here
auto&& retval = valptr->get();
^
./ThreadSafeClasses.h:269:4: note: in instantiation of member function 'Stack<std::__1::promise<InvEntry> >::pop_front' requested here
Stack()
^
./BDM_supportClasses.h:445:4: note: in instantiation of member function 'Stack<std::__1::promise<InvEntry> >::Stack' requested here
ZeroConfContainer(LMDBBlockDatabase* db,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<InvEntry>' has been explicitly
marked unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1422:1: error: 'promise<bool>' is unavailable: introduced in
macOS 10.8
promise<_Rp>::promise()
^
./BlockchainScanner.h:65:4: note: in instantiation of member function 'std::__1::promise<bool>::promise' requested here
BlockDataBatch(unsigned end, atomic<unsigned>* counter) :
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/future:1362:57: note: 'promise<bool>' has been explicitly marked
unavailable here
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_AVAILABILITY_FUTURE promise
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
make: *** [BlockUtils.o] Error 1

Getting the same.

Did you have any luck figuring out a workaround?

Ahhh. We had our deployment target set to 10.7. With Xcode7 this was fine and std::future worked.. Now for Xcode8 it needs to be 10.8 minimum. Why?

Hi, How did you fix it?

Didn't really fix it. In our CMAKE we just added something like this, so we could run Xcode 8 locally, while leaving the build slaves happily using 7.

set(DEPLOYMENT_TARGET "10.7")
if(${CMAKE_GENERATOR} STREQUAL "Xcode")
if(XCODE_VERSION VERSION_LESS "8.0")
set(DEPLOYMENT_TARGET "10.8")
endif()
endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET "${DEPLOYMENT_TARGET}")

Hi. Sorry about the late reply! Forgot about this thread until the problem popped up again under XCode 8.1. Anyway, no, I never found a workaround. Your solution's the only one I know of. Can you confirm that the code will run on 10.7 if compiled under XCode 7?


Thanks.

Xcode 8: C++11 compilation failure
 
 
Q