C99 usage guideline¶
From Ruby 2.7, we require C compiler to support C99 features that work on environments supported by platforms maintainers.
- C99 features that cannot be built on Travis/AppVeyor/RubyCI are prohibited.
- Ruby 2.7 requires Visual Studio 2013+, which is tested on AppVeyor and RubyCI.
- Ruby 2.7 requires Oracle Developer Studio 12+ or GCC on Solaris 10+, which are tested on RubyCI. (adding 12.4 and/or earlier is pending, but planned)
Known supported features¶
Here is a list of features that are known to work on both Visual Studio 2013 and Oracle Developer Studio 12.5, confirmed by this c99.c.
This is just for a quick reference to bypass testing on CI, and you do NOT need to update this list to use your favorite C99 feature as long as it works on Travis/AppVeyor/RubyCI.
- // comments
- mixed declarations and code
- designated initializers
- compound literals
- relaxed constraints on aggregate and union initialization
- trailing comma allowed in enum declaration
- stdbool.h seems to have been added in Oracle Solaris Studio 12.3, so we need to use missing/stdbool.h header for Oracle Solaris Studio 12.2 or earlier, which is included in our internal.h. See r66739.
restrictkeyword does not exist on Visual Studio 2013, but
__restrictexists and is used instead.
va_copydefinition like r62220 was problematic for cross compiling and removed in r62463.
r62191 was initially introduced for old Visual Studio. We may be able to just use
va_copywith Ruby 2.7's Visual Studio 2013 requirement.
- r62191 was initially introduced for old Visual Studio. We may be able to just use
Known missing features¶
- Visual Studio 2013
- variable length arrays
- some format specifier behaviors:
- size_t length modifier: %z
- infinite/indefinite/NaN conversion of floating point number
According to the header files committed in https://github.com/ruby/ruby/pull/2991,
We assume C99 for ruby itself but we don't assume languages of
extension libraries. They could be written in C++98.