When browsing through a draft of the standard (N4527), I found the following paragraph ([alg.c.library]):
The function signature:
bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
is replaced by the two declarations:
extern "C" void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*)); extern "C++" void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*));
And the same stuff for qsort
.
I also found in [dcl.link]:
If two declarations declare functions with the same name and parameter-type-list (8.3.5) to be members of the same namespace or declare objects with the same name to be members of the same namespace and the declarations give the names different language linkages, the program is ill-formed;
What is the purpose of these two extern
declaration of the same function? Why is this block not ill-formed?