mardi 10 août 2021

Compilation errors inside C++ stdlib when compiling for iOS 14.5 arm64

I'm getting weird compilation errors while compiling my library for arm64 architecture, iOS 14.5 SDK using -std=c++11 and -stdlib=libc++ flags. Compilation errors come from C++ stdlib files. The code being compiled:

#include "clock.hpp"
#include <chrono>

using namespace std::chrono;

namespace optar
{
namespace clock
{
int64_t millisecondTimestamp()
{
    milliseconds msec = duration_cast<milliseconds>(steady_clock::now().time_since_epoch());
    return msec.count();
};

int64_t microsecondTimestamp()
{
    microseconds usec = duration_cast<microseconds>(steady_clock::now().time_since_epoch());
    return usec.count();
};

int64_t nanosecondTimestamp()
{
    nanoseconds nsec = steady_clock::now().time_since_epoch();
    return nsec.count();
};

double unixTimestamp()
{
    auto now = system_clock::now().time_since_epoch();
    duration<double> sec = now;
    return sec.count();
}

int64_t millisecSinceEpoch()
{
    milliseconds msec = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
    return msec.count();
}
}
}

yields ~20 errors similar to (also see the screenshot attached):

In file included from /Users/peetonn/Documents/Work/optarLibrary/src/utils/clock.cpp:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/include/c++/v1/chrono:827:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/include/c++/v1/ctime:49:
In file included from /Users/peetonn/Documents/Work/optarLibrary/thirdparty/ros.framework/Headers/time.h:53:
In file included from /Users/peetonn/Documents/Work/optarLibrary/thirdparty/ros.framework/Headers/platform.h:38:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/include/c++/v1/string:506:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/include/c++/v1/string_view:175:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/include/c++/v1/__string:57:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/include/c++/v1/algorithm:643:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/include/c++/v1/memory:681:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/include/c++/v1/atomic:576:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/include/c++/v1/__threading_support:265:38: error: use of undeclared identifier 'chrono'
void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns);

I'm not quite sure what is happening. Originally thought of some faulty flags and/or std library, but still see this problem with other flag combinations (-stdlib=libstdc++, -std=c++14 -std=c++17). Any hints will be appreciated.

enter image description here

Aucun commentaire:

Enregistrer un commentaire