Following the documentation and compiling with gcc-11.2.0
like so
g++ -std=c++17 -pthread -O3 -flto -fPIC ...
I am not able to use localtime_s
in my program:
#define __STDC_WANT_LIB_EXT1__ 1
#include <time.h>
using SystemClock = std::chrono::system_clock;
const auto in_time_t = SystemClock::to_time_t(SystemClock::now());
struct tm buf; localtime_s(&in_time_t, &buf);
// error: there are no arguments to ‘localtime_s’ that depend on a template parameter,
// so a declaration of ‘localtime_s’ must be available [-fpermissive]
struct tm buf; std::localtime_s(&in_time_t, &buf);
// error: ‘localtime_s’ is not a member of ‘std’; did you mean ‘localtime’?
Am I doing something wrong or localtime_s
is not available in GCC? Or it is only available for pure C programs (for example, compiled with gcc -std=c11
)?
Thank you very much for your help!