Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation errors with libc++ (Mac OSX 10.9 Mavericks) #66

Closed
scpeters opened this issue Nov 11, 2013 · 2 comments
Closed

Compilation errors with libc++ (Mac OSX 10.9 Mavericks) #66

scpeters opened this issue Nov 11, 2013 · 2 comments

Comments

@scpeters
Copy link
Member

The new version of Mac OSX uses libc++ by default, rather than libstdc++, which causes a number of compilation errors. For example, when building TestVectorMath, it gives several complaints about operator overloading and templates:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/algorithm:3585:17: error: 
      no viable overloaded '+='
            __m += __delta;
            ~~~ ^  ~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/algorithm:3743:5: note: in
      instantiation of function template specialization 'std::__1::__sort<std::__1::__less<double, double> &,
      SimTK::VectorIterator<double, SimTK::VectorBase<double> > >' requested here
    __sort<_Comp_ref>(__first, __last, __comp);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/algorithm:3752:5: note: in
      instantiation of function template specialization 'std::__1::sort<SimTK::VectorIterator<double, SimTK::VectorBase<double>
      >, std::__1::__less<double, double> >' requested here
    _VSTD::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__config:300:15: note: 
      expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/./include/SimTKcommon/internal/VectorMath.h:358:5: note: in instantiation of
      function template specialization 'std::__1::sort<SimTK::VectorIterator<double, SimTK::VectorBase<double> > >' requested
      here
    std::sort(temp.begin(), temp.end());
    ^
/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/tests/TestVectorMath.cpp:331:20: note: in instantiation of function template
      specialization 'SimTK::sort<double>' requested here
        testVector(sort(vector), expectedVec);
                   ^

Full console output:

$ make TestVectorMath
...
[100%] Building CXX object SimTKcommon/tests/CMakeFiles/TestVectorMath.dir/TestVectorMath.cpp.o
cd /tmp/simbody-Fnqf/simbody-Simbody-3.3/build/SimTKcommon/tests && /usr/local/Library/ENV/4.3/clang++   -DSimTK_SIMBODY_AUTHORS=\"Michael.Sherman_Peter.Eastman\" -DSimTK_SIMBODY_COPYRIGHT_YEARS=\"2005-13\" -DSimTK_SIMBODY_SVN_REVISION="\"Unversioned directory\"" -DSimTK_SimTKCOMMON_AUTHORS=\"Michael.Sherman_Peter.Eastman\" -DSimTK_SimTKCOMMON_COPYRIGHT_YEARS=\"2005-10\" -DSimTK_SimTKCOMMON_LIBRARY_NAME=SimTKcommon -DSimTK_SimTKCOMMON_MAJOR_VERSION=3 -DSimTK_SimTKCOMMON_MINOR_VERSION=3 -DSimTK_SimTKCOMMON_PATCH_VERSION=0 -DSimTK_SimTKCOMMON_SVN_REVISION="\"Unversioned directory\"" -I/tmp/simbody-Fnqf/simbody-Simbody-3.3/Platform/Mac/include -I/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/./include -I/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/Scalar/include -I/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/SmallMatrix/include -I/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/Mechanics/include -I/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/BigMatrix/include -I/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/Geometry/include -I/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/Simulation/include -I/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/Random/include -I/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/Polynomial/include    -o CMakeFiles/TestVectorMath.dir/TestVectorMath.cpp.o -c /tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/tests/TestVectorMath.cpp
In file included from /tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/tests/TestVectorMath.cpp:24:
In file included from /tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/./include/SimTKcommon.h:32:
In file included from /tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/./include/SimTKcommon/basics.h:38:
In file included from /tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/./include/SimTKcommon/internal/common.h:234:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/complex:247:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/sstream:174:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/ostream:130:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__locale:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/string:434:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/algorithm:3585:17: error: 
      no viable overloaded '+='
            __m += __delta;
            ~~~ ^  ~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/algorithm:3743:5: note: in
      instantiation of function template specialization 'std::__1::__sort<std::__1::__less<double, double> &,
      SimTK::VectorIterator<double, SimTK::VectorBase<double> > >' requested here
    __sort<_Comp_ref>(__first, __last, __comp);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/algorithm:3752:5: note: in
      instantiation of function template specialization 'std::__1::sort<SimTK::VectorIterator<double, SimTK::VectorBase<double>
      >, std::__1::__less<double, double> >' requested here
    _VSTD::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__config:300:15: note: 
      expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/./include/SimTKcommon/internal/VectorMath.h:358:5: note: in instantiation of
      function template specialization 'std::__1::sort<SimTK::VectorIterator<double, SimTK::VectorBase<double> > >' requested
      here
    std::sort(temp.begin(), temp.end());
    ^
/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/tests/TestVectorMath.cpp:331:20: note: in instantiation of function template
      specialization 'SimTK::sort<double>' requested here
        testVector(sort(vector), expectedVec);
                   ^
In file included from /tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/tests/TestVectorMath.cpp:24:
In file included from /tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/./include/SimTKcommon.h:32:
In file included from /tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/./include/SimTKcommon/basics.h:38:
In file included from /tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/./include/SimTKcommon/internal/common.h:234:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/complex:247:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/sstream:174:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/ostream:130:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__locale:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/string:434:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/algorithm:3585:17: error: 
      no viable overloaded '+='
            __m += __delta;
            ~~~ ^  ~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/algorithm:3743:5: note: in
      instantiation of function template specialization 'std::__1::__sort<std::__1::__less<double, double> &,
      SimTK::VectorIterator<double, SimTK::RowVectorBase<double> > >' requested here
    __sort<_Comp_ref>(__first, __last, __comp);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/algorithm:3752:5: note: in
      instantiation of function template specialization 'std::__1::sort<SimTK::VectorIterator<double,
      SimTK::RowVectorBase<double> >, std::__1::__less<double, double> >' requested here
    _VSTD::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__config:300:15: note: 
      expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/./include/SimTKcommon/internal/VectorMath.h:365:5: note: in instantiation of
      function template specialization 'std::__1::sort<SimTK::VectorIterator<double, SimTK::RowVectorBase<double> > >' requested
      here
    std::sort(temp.begin(), temp.end());
    ^
/tmp/simbody-Fnqf/simbody-Simbody-3.3/SimTKcommon/tests/TestVectorMath.cpp:332:20: note: in instantiation of function template
      specialization 'SimTK::sort<double>' requested here
        testVector(sort(rowvector), expectedVec);
                   ^
2 errors generated.
make[3]: *** [SimTKcommon/tests/CMakeFiles/TestVectorMath.dir/TestVectorMath.cpp.o] Error 1
make[2]: *** [SimTKcommon/tests/CMakeFiles/TestVectorMath.dir/all] Error 2
make[1]: *** [SimTKcommon/tests/CMakeFiles/TestVectorMath.dir/rule] Error 2
make: *** [TestVectorMath] Error 2
@scpeters
Copy link
Member Author

The following is a partial fix:

diff --git a/SimTKcommon/BigMatrix/include/SimTKcommon/internal/BigMatrix.h b/SimTKcommon/BigMatrix/include/SimTKcommon/internal/BigMatrix.h
index 64fbbe4..943ca58 100644
--- a/SimTKcommon/BigMatrix/include/SimTKcommon/internal/BigMatrix.h
+++ b/SimTKcommon/BigMatrix/include/SimTKcommon/internal/BigMatrix.h
@@ -3632,6 +3632,11 @@ public:
         --index;
         return current;
     }
+    VectorIterator operator+=(ptrdiff_t n) {
+        assert (index+n-1 < vector.size());
+        index += n;
+        return *this;
+    }
     bool operator<(VectorIterator iter) const {
         return (index < iter.index);
     }

I'll make a pull request once I've tested it fully.

@sherm1
Copy link
Member

sherm1 commented Nov 20, 2013

Thanks, Steve! A couple of thoughts:

  • Should have a -= operator also to avoid future problems
  • Since ptrdiff_t is signed the assert should probably be something like
    assert(0 <= index+n && index+n <= vector.size());

scpeters added a commit to scpeters/simbody that referenced this issue Nov 20, 2013
Fix the assert statement per recommendation by @sherm1 and
add -= operator.
@sherm1 sherm1 closed this as completed in d0da7b0 Nov 21, 2013
sherm1 added a commit that referenced this issue Nov 21, 2013
Fix #66: add += and -= operators to VectorIterator class (needed by OSX 10.9's std library).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants