[libcxx] What C standard is assumed in libcxx?

Hi All,

libc++ assumes an underlying C library to provide lower level functionalities (and sometimes even other libraries like pthreads).

My question is, is there a minimum C standard required from the C library? I couldn’t find this documented anywhere.

For example, the current std::thread support (C++11) does not assume the underlying C library to be C11 compliant, it instead depends on pthreads. On the other hand, we do seem to assume a C11 compliant header (e.g. timespec).

This works OK for us at the moment (bits of C11 but mostly C99), but I’d like to get the general policy towards the C standard clarified.

I plan to update http://libcxx.llvm.org/index.html with the outcome of this discussion.


/ Asiri

I think you are confusing C11 functionality with basic POSIX functions.
While C11 might have merged a bunch of things from POSIX, things like
timespec are much older and wildly supported. That's unlike C11
threading for example.


OK, that makes sense.

So, libc++ essentially assumes C99 + some POSIX extensions like pthreads et. al.

Is it OK to assume that libc++ will not depend on C11 functionality in future?


/ Asiri

std::atomic is implemented in terms of the C11 _Atomic feature. That’s a language feature though, and not a library feature. I think you are mostly concerned with the library features needed.

I’ve had success with a C99 Dinkumware library. I think the backing source predates C11. I’ve had to do a fair amount on the pthread and posix side of things.

To be honest though, I don’t know that it is entirely productive to list out the dependencies in as abstract a form as “C99 compliant + POSIX 20xx compliant”. In practice, libcxx and libcxxabi are developed against specific OSes and specific C libraries. Support is added for those platforms. GLIBC, MUSL, UCLIBC, NEWLIB, and a bunch of other C libraries all claim support for C99, but there tends to be little warts in each library that requires libcxx intervention.

Thanks Ben.

Yes, my concern is about library features. As long as libcxx does not assume C11 (or later) library features, we are mostly OK :slight_smile:

/ Asiri