fix(libSceLibcInternal): build TimeGetFields with Apple clang #22056

Merged
kurexw merged 1 commit from upstream-pr/22056 into main 2026-11-17 06:35:12 +00:00
kurexw commented 2026-11-17 03:31:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kurexw on 2026-11-17T03:31:09Z.


What

#21895 added core/libs/prx/libSceLibcInternal/TimeGetFields.cpp. Apple clang refuses to compile it, so every macOS build of main stops there. Three calls convert a const void* vtable slot (caseMethods/classificationMethods, declared const void* in GuestLocale.hpp) straight to a function pointer:

TimeGetFields.cpp:204:28: error: reinterpret_cast from 'const void *' to 'DoToLower' (aka 'char (*)(const GuestLocale::Facet *, char)') casts away qualifiers
TimeGetFields.cpp:229:24: error: reinterpret_cast from 'const void *' to 'DoIs' (aka 'bool (*)(const GuestLocale::Facet *, short, unsigned short)') casts away qualifiers
TimeGetFields.cpp:250:24: error: reinterpret_cast from 'const void *' to 'DoToLower' (aka 'unsigned short (*)(const GuestLocale::Facet *, unsigned short)') casts away qualifiers

This PR drops the qualifier first, with reinterpret_cast<Fn>(const_cast<void*>(slot)), as the repository already does for other const slots (StandardExceptions.cpp, InspectorFrontendRouter.cpp). The same function is called with the same arguments, so behaviour doesn't change.

Tested

macOS 27.2 on an Apple M4, with Apple clang for an x86-64 build under Rosetta.

  • On main at b412486d3e, TimeGetFields.cpp.o fails with the three errors above.
  • With this PR, ninja guest_libc_internal_time_get_fields_tests builds with no errors. The object adds no warnings.
  • ctest -R '^guest_libc_internal_time_get_fields$' passed in three runs out of three.
  • I didn't build this on Linux or Windows. The change only adds a const_cast before the existing cast, and those compilers already accepted the original line.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5350040855 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22056). Originally posted by [kurexw](https://github.com/kurexw) on 2026-11-17T03:31:09Z. --- ### What #21895 added `core/libs/prx/libSceLibcInternal/TimeGetFields.cpp`. Apple clang refuses to compile it, so every macOS build of `main` stops there. Three calls convert a `const void*` vtable slot (`caseMethods`/`classificationMethods`, declared `const void*` in `GuestLocale.hpp`) straight to a function pointer: ``` TimeGetFields.cpp:204:28: error: reinterpret_cast from 'const void *' to 'DoToLower' (aka 'char (*)(const GuestLocale::Facet *, char)') casts away qualifiers TimeGetFields.cpp:229:24: error: reinterpret_cast from 'const void *' to 'DoIs' (aka 'bool (*)(const GuestLocale::Facet *, short, unsigned short)') casts away qualifiers TimeGetFields.cpp:250:24: error: reinterpret_cast from 'const void *' to 'DoToLower' (aka 'unsigned short (*)(const GuestLocale::Facet *, unsigned short)') casts away qualifiers ``` This PR drops the qualifier first, with `reinterpret_cast<Fn>(const_cast<void*>(slot))`, as the repository already does for other const slots (`StandardExceptions.cpp`, `InspectorFrontendRouter.cpp`). The same function is called with the same arguments, so behaviour doesn't change. ### Tested macOS 27.2 on an Apple M4, with Apple clang for an x86-64 build under Rosetta. - On `main` at b412486d3e, `TimeGetFields.cpp.o` fails with the three errors above. - With this PR, `ninja guest_libc_internal_time_get_fields_tests` builds with no errors. The object adds no warnings. - `ctest -R '^guest_libc_internal_time_get_fields$'` passed in three runs out of three. - I didn't build this on Linux or Windows. The change only adds a `const_cast` before the existing cast, and those compilers already accepted the original line. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!22056
No description provided.