You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
zstr: inline char * synonym arm on every _Generic Zstr dispatch
MSVC's C `_Generic` follows the C standard, which types string
literals as `char[N]` decaying to `char *`. The codebase had been
relying on gcc/clang's `-Wwrite-strings` (a non-standard extension)
to retype literals as `const char *` so the `Zstr` arms would match;
on MSVC pure-C the dispatch fails. `/Zc:strictStrings` is a C++-only
flag with no effect in C mode.
Add an inline `char *:` synonym arm next to every `Zstr:` arm across
17 headers (49 sites). Both arms route through the same backend with
a `(Zstr)` cast: `Zstr` is `const char *`, so the input cannot be
mutated through the parameter and the library's read-only invariant
on `Zstr` arguments is preserved.
No wrapper macro hides the `_Generic` -- inlining both arms at every
site is the project convention. The convention is documented in
CODING-CONVENTIONS.md and the Zstr.h doc comment.
Docs:
- CODING-CONVENTIONS.md: rule rewritten; StrStartsWith and FileGetSize
skeleton examples updated to show the Zstr + char * pair; the
Compiler-flags section corrected to document /Zc:strictStrings as
C++-only with no effect in C mode.
- Zstr.h: typedef doc comment updated.
- meson.build: drop the no-op /Zc:strictStrings from the MSVC branch;
inline NOTE explaining why it is intentionally absent.
Also folded in:
- Tests/Std/MachO.c: bind _NSGetExecutablePath's char path[4096] to
a `Zstr path` local before passing to `MachoOpen` so the Darwin
test builds under the same Zstr dispatch.
Verified:
- Linux gcc: 104/104 tests pass.
- Mac clang: 99/99 tests pass (MachO suite exercises both the path
binding and the StrPushBackMany("\\x") hex-escape shape).
- MSVC: pending CI.
0 commit comments