Skip to content

Commit c1aa85f

Browse files
gtbuchananclaude
andauthored
Declare test compat.h shims inline to avoid -Wunused-function (#24)
claude-wrapper.c sets but never unsets env after the LD_PRELOAD-overwrite change, so the plain-`static` unsetenv shim was unused in that translation unit and failed `-Werror` on Windows. `static inline` exempts header helpers from -Wunused-function. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 76c483e commit c1aa85f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

test/compat.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,25 @@
77
* build to supply them; it is NEVER part of the shipped Termux build, so
88
* production code stays free of host-portability cruft. On POSIX hosts the
99
* block compiles to nothing and the real libc functions are used.
10+
*
11+
* The shims are `inline` so a translation unit that uses only one of them
12+
* (e.g. claude-wrapper.c sets but never unsets) doesn't trip -Wunused-function.
1013
*/
1114
#ifndef CLAUDE_WRAPPER_TEST_COMPAT_H
1215
#define CLAUDE_WRAPPER_TEST_COMPAT_H
1316

1417
#if defined(_WIN32)
1518
#include <stdlib.h>
1619

17-
static int setenv(const char *name, const char *value, int overwrite) {
20+
static inline int setenv(const char *name, const char *value, int overwrite) {
1821
if (!overwrite && getenv(name) != NULL) {
1922
return 0;
2023
}
2124
return _putenv_s(name, value);
2225
}
2326

2427
/* _putenv_s(name, "") removes the variable on Windows (getenv → NULL). */
25-
static int unsetenv(const char *name) { return _putenv_s(name, ""); }
28+
static inline int unsetenv(const char *name) { return _putenv_s(name, ""); }
2629
#endif /* _WIN32 */
2730

2831
#endif /* CLAUDE_WRAPPER_TEST_COMPAT_H */

0 commit comments

Comments
 (0)