I'm running XCode 4.5, Apple clang 4.0 (LLVM 3.1), and Ogre 1.8.1. I've verified this error outside of my project. In a nutshell, it looks like Clang doesn't like incomplete types as template parameters in libc++. (Source: http://stackoverflow.com/questions/1006 ... 7#11514677 )
This is the exact error:
Code: Select all
In file included from /Volumes/MacData/Users/edwards/Projects/test/TestProject/TestProject/main.cpp:11:
In file included from /Library/Frameworks/Ogre.framework/Headers/Ogre.h:31:
In file included from /Library/Frameworks/Ogre.framework/Headers/OgrePrerequisites.h:334:
In file included from /Library/Frameworks/Ogre.framework/Headers/OgreStdHeaders.h:122:
In file included from /Library/Frameworks/Ogre.framework/Headers/Threading/OgreThreadHeaders.h:30:
In file included from /Library/Frameworks/Ogre.framework/Headers/Threading/OgreThreadHeadersBoost.h:38:
In file included from /usr/local/include/boost/thread/recursive_mutex.hpp:16:
In file included from /usr/local/include/boost/thread/pthread/recursive_mutex.hpp:12:
In file included from /usr/local/include/boost/thread/locks.hpp:14:
In file included from /usr/local/include/boost/thread/thread_time.hpp:11:
In file included from /usr/local/include/boost/date_time/posix_time/posix_time_types.hpp:16:
/usr/local/include/boost/date_time/posix_time/posix_time_duration.hpp:24:21: warning: implicit conversion loses integer precision: 'long' to 'hour_type' (aka 'int') [-Wshorten-64-to-32]
time_duration(h,0,0)
~~~~~~~~~~~~~ ^
/usr/local/include/boost/date_time/posix_time/posix_time_duration.hpp:35:23: warning: implicit conversion loses integer precision: 'long' to 'min_type' (aka 'int') [-Wshorten-64-to-32]
time_duration(0,m,0)
~~~~~~~~~~~~~ ^
/usr/local/include/boost/date_time/posix_time/posix_time_duration.hpp:46:25: warning: implicit conversion loses integer precision: 'long' to 'sec_type' (aka 'int') [-Wshorten-64-to-32]
time_duration(0,0,s)
~~~~~~~~~~~~~ ^
In file included from /Volumes/MacData/Users/edwards/Projects/test/TestProject/TestProject/main.cpp:11:
In file included from /Library/Frameworks/Ogre.framework/Headers/Ogre.h:31:
In file included from /Library/Frameworks/Ogre.framework/Headers/OgrePrerequisites.h:334:
In file included from /Library/Frameworks/Ogre.framework/Headers/OgreStdHeaders.h:35:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:212:9: error: field has incomplete type 'Ogre::Plane'
_Tp __value_;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:1889:54: note: in instantiation of template class 'std::__1::__list_node<Ogre::Plane, void *>' requested here
decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...)), true_type())
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:1890:1: note: while substituting deduced template arguments into function template '__is_constructible_test' [with _Tp = Ogre::STLAllocator<std::__1::__list_node<Ogre::Plane, void *>, Ogre::CategorisedAllocPolicy<0>>, _Args = <no value>]
__is_constructible_test(_Tp&&, _Args&& ...);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:1949:14: note: in instantiation of template class 'std::__1::__is_constructible<false, Ogre::STLAllocator<std::__1::__list_node<Ogre::Plane, void *>, Ogre::CategorisedAllocPolicy<0>>, Ogre::STLAllocator<std::__1::__list_node<Ogre::Plane, void *>, Ogre::CategorisedAllocPolicy<0>> &>' requested here
: public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:1975:14: note: in instantiation of template class 'std::__1::__is_constructible_void_check<false, Ogre::STLAllocator<std::__1::__list_node<Ogre::Plane, void *>, Ogre::CategorisedAllocPolicy<0>>, Ogre::STLAllocator<std::__1::__list_node<Ogre::Plane, void *>, Ogre::CategorisedAllocPolicy<0>> &>' requested here
: public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:2455:34: note: in instantiation of template class 'std::__1::is_constructible<Ogre::STLAllocator<std::__1::__list_node<Ogre::Plane, void *>, Ogre::CategorisedAllocPolicy<0>>, Ogre::STLAllocator<std::__1::__list_node<Ogre::Plane, void *>, Ogre::CategorisedAllocPolicy<0>> &>' requested here
: __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:2583:14: note: (skipping 2 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
: public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/memory:2386:15: note: in instantiation of template class 'std::__1::__libcpp_compressed_pair_imp<unsigned long, Ogre::STLAllocator<std::__1::__list_node<Ogre::Plane, void *>, Ogre::CategorisedAllocPolicy<0>>, 0>' requested here
: private __libcpp_compressed_pair_imp<_T1, _T2>
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:513:52: note: in instantiation of template class 'std::__1::__compressed_pair<unsigned long, Ogre::STLAllocator<std::__1::__list_node<Ogre::Plane, void *>, Ogre::CategorisedAllocPolicy<0>>>' requested here
__compressed_pair<size_type, __node_allocator> __size_alloc_;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:770:15: note: in instantiation of template class 'std::__1::__list_imp<Ogre::Plane, Ogre::STLAllocator<Ogre::Plane, Ogre::CategorisedAllocPolicy<0>>>' requested here
: private __list_imp<_Tp, _Alloc>
^
/Library/Frameworks/Ogre.framework/Headers/OgrePrerequisites.h:508:27: note: in instantiation of template class 'std::__1::list<Ogre::Plane, Ogre::STLAllocator<Ogre::Plane, Ogre::CategorisedAllocPolicy<0>>>' requested here
typedef typename std::list<T, A>::iterator iterator;
^
/Library/Frameworks/Ogre.framework/Headers/OgreMath.h:627:35: note: in instantiation of template class 'Ogre::list<Ogre::Plane, Ogre::STLAllocator<Ogre::Plane, Ogre::CategorisedAllocPolicy<0>>>' requested here
const Ray& ray, const list<Plane>::type& planeList,
^
/Library/Frameworks/Ogre.framework/Headers/OgrePrerequisites.h:236:11: note: forward declaration of 'Ogre::Plane'
class Plane;
^
This unfortunately seems like Ogre's problem, but is it something that may be fixed in 1.8? Has anyone else encountered this issue? Is there a workaround short of removing our dependency on libc++?The following code is invalid, but compilers are allowed to accept it:The standard says that types which don't depend on template parameters must be complete when a template is defined if they affect the program's behavior. However, the standard also says that compilers are free to not enforce this rule. Most compilers enforce it to some extent; for example, it would be an error in GCC to write opts.ForceReads in the code above. In Clang, we feel that enforcing the rule consistently lets us provide a better experience, but unfortunately it also means we reject some code that other compilers accept.Code: Select all
class IOOptions; template <class T> bool read(T &value) { IOOptions opts; return read(opts, value); } class IOOptions { bool ForceReads; }; bool read(const IOOptions &opts, int &x); template bool read<>(int &);
(Most of this code was written for VC++ 2010, where C++11 was supported just fine. It's only now that I'm working on the OSX port that I'm encountering this issue.)