[flang-commits] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)
David Truby via flang-commits
flang-commits at lists.llvm.org
Fri Nov 10 07:05:10 PST 2023
================
@@ -13,8 +13,25 @@
#include "tools.h"
#include "flang/Runtime/descriptor.h"
#include <cstdlib>
+#include <ctime>
#include <limits>
+#ifdef _WIN32
+inline const char *ctime_alloc(
+ char *buffer, size_t bufsize, const time_t cur_time) {
+ int error = ctime_s(buffer, bufsize, &cur_time);
+ assert(error == 0 && "ctime_s returned an error");
+ return buffer;
+}
+#else
+inline const char *ctime_alloc(
+ char *buffer, size_t bufsize, const time_t cur_time) {
+ const char *res = ctime_r(&cur_time, buffer);
----------------
DavidTruby wrote:
Never mind, POSIX_C_SOURCE doesn't exist on macos.... Isn't cross platform development fun? Keep it as-is
https://github.com/llvm/llvm-project/pull/71222
More information about the flang-commits
mailing list