Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
t.cpp
t.cpp(10): error C2039: 'localtime_s': is not a member of 'std'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\ctime(17):
note: see declaration of 'std'
t.cpp(10): error C2664: 'errno_t localtime_s(tm *const ,const time_t *const )':
cannot convert argument 2 from 'time_t (__cdecl *)(time_t *const )' to 'const time_t *const '
t.cpp(10): note: There is no context in which this conversion is possible
The following C++ code does not compile with VS2015: [code]#include #include
void main() { const time_t t = std::time(nullptr);
std::tm tm = {};
std::localtime_s(&tm, &time); } [/code] The error messages are: [code]Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86 Copyright (C) Microsoft Corporation. All rights reserved.
t.cpp t.cpp(10): error C2039: 'localtime_s': is not a member of 'std' C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\ctime(17): note: see declaration of 'std' t.cpp(10): error C2664: 'errno_t localtime_s(tm *const ,const time_t *const )': cannot convert argument 2 from 'time_t (__cdecl *)(time_t *const )' to 'const time_t *const ' t.cpp(10): note: There is no context in which this conversion is possible [/code] What can be a workaround? Note: using [code]std::localtime()[/code] is not an option.