New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using C99 #2064

Closed
wants to merge 1 commit into
base: trunk
from

Conversation

2 participants
@k0kubun
Copy link
Member

k0kubun commented Jan 4, 2019

https://bugs.ruby-lang.org/issues/15347

To be discussed at DevelopersMeeting 20190110 Japan. We already started to use some C99 features since r66597, and enabled C99 in configure level since r66598 and r66605. This patch just changes C90 build check on Travis to C99.

Here is the draft of our C99 dialect documentation to be posted:
Moved to https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/C99.


C99 usage guideline

From Ruby 2.7, we require C compiler to support C99 features that work on environments supported by platforms maintainers.

General rule

  • 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

See also:

Discussions

  • 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.
  • restrict keyword does not exist on Visual Studio 2013, but __restrict exists and is used instead.
  • Switching va_copy definition 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_copy with Ruby 2.7's Visual Studio 2013 requirement.

Known missing features

@shyouhei

This comment has been minimized.

Copy link
Member

shyouhei commented Jan 6, 2019

Sorry, just a silly question: what is "incomplete format specifier support"?

@k0kubun

This comment has been minimized.

Copy link
Member

k0kubun commented Jan 6, 2019

I should have clarified that.

I'm not sure about the complete list, but what I know is:

  1. %z prefix support is missing in https://docs.microsoft.com/en-us/cpp/c-runtime-library/format-specification-syntax-printf-and-wprintf-functions?view=vs-2017

  2. also the same document mentions the floating-point conversion behavior for infinite/indefinite/NaN:

Starting in Visual Studio 2015, if the argument that corresponds to a floating-point conversion specifier (a, A, e, E, f, F, g, G) is infinite, indefinite, or NaN, the formatted output conforms to the C99 standard.

Before Visual Studio 2015, the CRT used a different, non-standard format for output of infinite, indefinite, and NaN values

@shyouhei

This comment has been minimized.

Copy link
Member

shyouhei commented Jan 7, 2019

As fara as I understand, we don't use libc-provided printf series because they are locale dependent. For instance rb_raise can take printf-like format specifiers, and reroutes it to rb_vsprintf defined in sprintf.c.

The printf glitch should not be a serious problem to us.

@matzbot matzbot closed this in ec336fb Jan 10, 2019

@k0kubun k0kubun deleted the k0kubun:c99 branch Jan 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment