omit declaration of basename wrongly interpreted as prototype in C++
authorRich Felker <dalias@aerifal.cx>
Wed, 9 May 2012 15:47:06 +0000 (11:47 -0400)
committerRich Felker <dalias@aerifal.cx>
Wed, 9 May 2012 15:47:06 +0000 (11:47 -0400)
commit37bb3cce4598c19288628e675eaf1cda6e96958f
tree5a31a0a48fb89d0490997c97d208b10ad9c76e8f
parent0e195dfaa4902a73179f7ab296d47f01d3518ad3
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