From 37bb3cce4598c19288628e675eaf1cda6e96958f Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 9 May 2012 11:47:06 -0400 Subject: omit declaration of basename wrongly interpreted as prototype in C++ the non-prototype declaration of basename in string.h is an ugly compromise to avoid breaking 2 types of broken software: 1. programs which assume basename is declared in string.h and thus would suffer from dangerous pointer-truncation if an implicit declaration were used. 2. programs which include string.h with _GNU_SOURCE defined but then declare their own prototype for basename using the incorrect GNU signature for the function (which would clash with a correct prototype). however, since C++ does not have non-prototype declarations and interprets them as prototypes for a function with no arguments, we must omit it when compiling C++ code. thankfully, all known broken apps that suffer from the above issues are written in C, not C++. --- include/string.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/string.h b/include/string.h index 4aa930ed..8cf0ee9d 100644 --- a/include/string.h +++ b/include/string.h @@ -85,8 +85,10 @@ char *strcasestr(const char *, const char *); char *strsep(char **, const char *); void *memrchr(const void *, int, size_t); void *mempcpy(void *, const void *, size_t); +#ifndef __cplusplus char *basename(); #endif +#endif #ifdef __cplusplus } -- cgit v1.2.1