Global visibility of C11 functions in C++11 and C++17 in stdlib.h
In stdlib.h the strategy is to declare ISO standard specific functions/types in /usr/include/iso/stdlib_XXX.h for both C and C++ then include them.
If the language is C++ then functions/types are declared in the std namespace in iso/stdlib_XXX.h and only put in the global namespace in stdlib.h.
This is to cope with the requirement that use of C++ functions from C headers requires them to exist both in :: and std::.
std::size_t is declared in:
then if __cplusplus >= 199711L it is placed in the global namespace as well.
Functions defined in stdlib_c11.h are also declared in the std::namespace but there is no corresponding declaration in the global namespace.
This seems to have been the reason why an explicit "using std::aligned_alloc;" was required from gcc-7 onwards in libstdc++-v3/libsupc++/new_opa.cc, as well as the cause of compilation failure for gcc-8.
For C11 functions used in C++11 and C++17 global visibilty seems required in stdlib.h such as:
* Allow global visibility for symbols defined in
* C++ "std" namespace in <iso/stdlib_c11.h>.
#if __cplusplus >= 201103L
#if __cplusplus >= 201703L
For C++11 functions refer to:
For C++17 aligned_alloc refer to:
Adding Robert Mustacchi as watcher since he added support for C11.
Updated by Electric Monk about 3 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
commit 0df48811699b83d09c552548effcb1718d6ff1d0 Author: Aurélien Larcher <email@example.com> Date: 2018-05-23T02:11:32.000Z 9545 Global visibility of C11 functions in C++11 and C++17 in stdlib.h Reviewed by: Igor Kozhukhov <firstname.lastname@example.org> Reviewed by: Andy Fiddaman <email@example.com> Reviewed by: Robert Mustacchi <firstname.lastname@example.org> Approved by: Gordon Ross <email@example.com>