libc::types::common::c99 only contains a small subset of actual C99 integer types.
Recently I was trying to interface with a C library that uses some of the other int types and it turned to be surprisingly difficult.
Another missing C99 type is _Bool, defined in stdbool.h
Especially the *_fast* types seem to be widely used. I’m not sure about actual merit of these ‘fast’ types, but that’s beside the point, what is important here is that people seem to be using them in library interfaces and sometimes we need to interface with those libraries.
Rust’s liblibc seems to define all the integer types by hand per architecture. Wouldn’t it perhaps be easier to write a snippet of a C code that would figure out the size of each integer? As far as I know, the build process has to use C/C++ compiler for LLVM anyway…
Yeah, they're in the standard. Some of them are optional.
I realized generating the definition with a C snippet is not actually that easy, because not all compilers support C99's types. MSVC, for example, doesn't support C99 at all as far as I know. The code would probably need to detect this somehow...
For now I've put up a crate that provides these types:
@vojtechkral
Support of the C library in libc is far from being complete.
I have an (unfinished and a bit outdated) table of entities in the C library, extracted form the C11 standard, and and entities in Rust libc - https://github.com/petrochenkov/c11lib, feel free to improve it and use it as a reference for adding the missing features in libc.
@mrecstdint.h is implemented in VS2012, inttypes.h is implemented in VS2013, and VS2015 contains a full rewrite of the C library (modulo tgmath.h requiring C11 support from compiler) with all the missing parts filled and non-conformances fixed.
@vojtechkral We actually use MinGW to build Rust on Windows. There are plans to get it working with MSVC eventually though.
Adding type definitions that the underlying libc doesn’t have don’t hurt so long as you correctly predict what the type definitions will be when the actual libc does add support for them. Functions that don’t exist will simply result in linker errors if someone attempts to use them.