[PATCH] Prevent GCC 6 <cstdlib> from including /usr/include/stdlib.h

Marc Glisse marc.glisse@inria.fr
Mon Jun 13 09:14:00 GMT 2016


On Sat, 11 Jun 2016, Florian Weimer wrote:

> There is a need to wrap around glibc headers (do some stuff before and after 
> <stdlib.h> and other headers are included) to get support for some C++ 
> functionality, in addition to other header file coordination work.
>
> It's not that we do point releases to add C++ support to our headers, so I 
> can see why GCC is doing this.

Note that gcc doesn't need to do it this way. Currently, taking abs as 
a random example:

libc-stdlib.h declares abs in the global namespace
gcc-cstdlib imports it in namespace std and adds some overloads
gcc-stdlib.h imports the std overloads back to the global namespace

We could just as well have:
libc-stdlib.h declares abs in the global namespace
gcc-stdlib.h adds some overloads in the global namespace
gcc-cstdlib imports the lot in namespace std

where gcc's stdlib.h would #include_next libc's stdlib.h, the usual 
scenario for #include_next. Would that help or would we get exactly the 
same issue?

-- 
Marc Glisse



More information about the Libc-alpha mailing list