[libc-commits] [libc] [libc] Add `ctime_s` (PR #110676)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Wed Jan 8 11:05:19 PST 2025
================
@@ -37,6 +37,14 @@ functions:
arguments:
- type: const time_t *
- type: char *
+ - name: ctime_s
+ standard:
+ - stdc
+ return_type: errno_t
+ arguments:
+ - type: char *
+ - type: rsize_t
+ - type: const time_t *
----------------
nickdesaulniers wrote:
For the build failure, the issue is in a file you did not touch directly, `libc/src/time/asctime_r.cpp`. It includes `libc/src/time/asctime_r.h`, which includes `time.h` which is dynamically built at build time of llvm-libc since this is a "full build" (`-DLLVM_LIBC_FULL_BUILD=ON` is set in the buildbot's cmake invocation as seen in the logs).
The issue is that now anyone who includes the generated time.h will see a declaration of `ctime_s` and its return type of `errno_t` and its parameter of type `rsize_t` EVEN when they did not first `#define __STDC_WANT_LIB_EXT1__ 1`. IIRC, we added a field for hdrgen called `guard` which should wrap the declaration in a preprocessor guard.
So to fix the presubmit build failure, I think you just need to add:
```suggestion
- type: const time_t *
guard: __STDC_WANT_LIB_EXT1__
```
https://github.com/llvm/llvm-project/pull/110676
More information about the libc-commits
mailing list