Skip to content

Compile error in traits.hpp on OSX #341

Closed
@astrodroid

Description

@astrodroid

Hi,

I am using cereal to load game scenario/map data from file. So far this was working very well. But a couple of days ago, I had to move the classes that cereal serialises away from the game project in a separate static library that is used to calculate the objects position etc..

However as soon as I reference the cereal headers within that static library I encounter a compile error on the traits.hpp file:

    namespace detail
    {
      struct shared_from_this_wrapper
      {
        template <class U>
        static auto **check**( U const & t ) -> decltype( ::cereal::access::shared_from_this(t), std::true_type() );  _//error: Expected member name or ';' after declaration specifiers_

        static auto **check**( ... ) -> decltype( std::false_type() ); _//error: Expected member name or ';' after declaration specifiers_

        template <class U>
        static auto get( U const & t ) -> decltype( t.shared_from_this() );
      };
    }

    //! Determine if T or any base class of T has inherited from std::enable_shared_from_this
    template<class T>
    struct has_shared_from_this : decltype(detail::shared_from_this_wrapper::**check**(std::declval<T>())) _//error: Expected unqualified-id_
    { };

The problem is a bit confusing as this only happens when compiling for OSX and not for iOS. If I understood what is happening correctly, it is not that the static check that is failing, but the compiler appears to be calling a macro called check contained within "AssertMacros.h" :

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
MacOSX10.11.sdk/usr/include/AssertMacros.h:1291:28: note: expanded from macro 'check'
        #define check(assertion)  __Check(assertion)

At the same time the same piece of code that doesn't work within the staticlibrary works fine if called from the main game project, for both iOS and OSX.

For now I have worked-around this issue by renaming the check methods within traits.hpp to "check_" which resolves the issue for me.

This is the full error log:
http://pastebin.com/6GPH6D50

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions