[libc-commits] [libc] [libc] Add `ctime_s` (PR #110676)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Tue Jan 7 10:34:09 PST 2025


================
@@ -0,0 +1,25 @@
+//===-- Implementation header of ctime_s ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_TIME_CTIME_S_H
+#define LLVM_LIBC_SRC_TIME_CTIME_S_H
+
+#define __STDC_WANT_LIB_EXT1__ 1
----------------
nickdesaulniers wrote:

I'd still like this fixed please:

```diff
diff --git a/libc/src/time/ctime_s.cpp b/libc/src/time/ctime_s.cpp
index 27fd682a3af9..b3e3a3fbb0a6 100644
--- a/libc/src/time/ctime_s.cpp
+++ b/libc/src/time/ctime_s.cpp
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define __STDC_WANT_LIB_EXT1__ 1
+
 #include "ctime_s.h"
 #include "hdr/errno_macros.h"
 #include "src/__support/CPP/limits.h"
diff --git a/libc/src/time/ctime_s.h b/libc/src/time/ctime_s.h
index 7c01eab083ae..decdcd91a080 100644
--- a/libc/src/time/ctime_s.h
+++ b/libc/src/time/ctime_s.h
@@ -9,8 +9,6 @@
 #ifndef LLVM_LIBC_SRC_TIME_CTIME_S_H
 #define LLVM_LIBC_SRC_TIME_CTIME_S_H
 
-#define __STDC_WANT_LIB_EXT1__ 1
-
 #include "hdr/types/rsize_t.h"
 #include "hdr/types/time_t.h"
 #include "src/__support/macros/config.h"
diff --git a/libc/test/src/time/ctime_s_test.cpp b/libc/test/src/time/ctime_s_test.cpp
index be8d174413a1..836f0de855b0 100644
--- a/libc/test/src/time/ctime_s_test.cpp
+++ b/libc/test/src/time/ctime_s_test.cpp
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define __STDC_WANT_LIB_EXT1__ 1
+
 #include "hdr/errno_macros.h"
 #include "src/errno/libc_errno.h"
 #include "src/time/ctime_s.h"
```
perhaps the rule of thumb would be: any translation unit referring to `RSIZE_MAX` should `#define __STDC_WANT_LIB_EXT1__ 1` BEFORE any `#include` preprocessor directives.

https://github.com/llvm/llvm-project/pull/110676


More information about the libc-commits mailing list