Skip to content

Commit 725e17e

Browse files
committed
remove non-prototype declaration of basename from string.h
commit 37bb3cc suppressed the declaration for C++, where it is wrongly interpreted as declaring the function as taking no arguments. with C23 removing non-prototype declarations, that problem is now also relevant to C. the non-prototype declaration for basename originates with commit 06aec8d, where it was designed to avoid conflicts with programs which declare basename with the GNU signature taking const char *. that change was probably misguided, as it represents not only misaligned expectations with the caller, but also undefined behavior (calling a function that's been declared with the wrong type). we could opt to fix the declaration, but since glibc, with the gratuitously incompatible GNU-basename function, seems to be the only implementation that declares it in string.h, it seems better to just remove the declaration. this provides some warning if applications are being built expecting the GNU behavior but not getting it. if we declared it here, it would only produce a warning if the caller also declares it themselves (rare) or if the caller attempts to pass a const-qualified pointer.
1 parent 6be7689 commit 725e17e

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

include/string.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ char *strchrnul(const char *, int);
9595
char *strcasestr(const char *, const char *);
9696
void *memrchr(const void *, int, size_t);
9797
void *mempcpy(void *, const void *, size_t);
98-
#ifndef __cplusplus
99-
char *basename();
100-
#endif
10198
#endif
10299

103100
#ifdef __cplusplus

0 commit comments

Comments
 (0)