According to wiki page of glibc, glibc directly supports C++ nowadays. To the best of my knowledge, glibc is just a C library, and has no C++ standard library. Somebody may argue that there is some latent support for C++. But this reference explicitly denote that glibc directly supports C++. How can that be possible??
wiki page of glibc:https://en.wikipedia.org/wiki/Glibc
The GNU C Library, commonly known as glibc, is the GNU Project implementation of the C standard library. It is a wrapper around the system calls of the Linux kernel for application use. Despite its name, it now also directly supports C++ (and, indirectly, other programming languages).
I search for header file in source code of glibc-2.18, and it seems that there is no C++ headers.
"Directly supports" probably means all the care that's been put into the C library to make it usable from C++ and other languages. From the README:
The GNU C Library is the standard system C library for all GNU systems, and is an important part of what makes up a GNU system. It provides the system API for all programs written in C and C-compatible languages such as C++ and Objective C; the runtime facilities of other programming languages use the C library to access the underlying operating system.
It does however not contain C++ headers. It does however contain some ~900 lines mentioning __cplusplus to make it useable from C++. It also has a few (36) extern "C++" declared functions, mainly in math.h, stdlib.h, string.h and wchar.h.
A commit from 2013 mentions:
In the
string/string.handstring/strings.hheaders, we have a couple of macros that "tell the caller that we provide correct C++ prototypes" according to the comment; they are used to determine whether to wrap some prototypes in"extern "C++"" (and provide multiple overloads of them, and some other magic) when__cplusplusis defined.
So, it is a C library, where adaptions for other languages to be able to use it has been made where needed.
The "it now also directly supports C++" words were added to the glibc Wikipedia page in this version, on 22 March 2015. The differences can be seen at https://en.wikipedia.org/w/index.php?title=Glibc&diff=prev&oldid=653048486
The glibc version history on that pages mentions this for glibc 2.18:
2.18 August 2013 Improved C++11 support...
Per the glibc 2.18 change log, we find this:
Add support for calling C++11 thread_local object destructors on thread and program exit. This needs compiler support for offloading C++11 destructor calls to glibc.
A quick reading of the glibc change logs from 2.19 to 2.35 available at https://abi-laboratory.pro/index.php?view=timeline&l=glibc does not seem to document any other C++ support being added to glibc.
So, if you account for cleaning up C++11 thread_local objects, glibc does "support" C++.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With