Skip to content

Fixing __has_include(<stdckdint.h>) compilation error#16802

Open
darkain wants to merge 1 commit intoruby:masterfrom
darkain:patch-1
Open

Fixing __has_include(<stdckdint.h>) compilation error#16802
darkain wants to merge 1 commit intoruby:masterfrom
darkain:patch-1

Conversation

@darkain
Copy link
Copy Markdown

@darkain darkain commented Apr 28, 2026

The very thing the conditional for __has_include is trying to handle, is causing compilation to break.

This file was brought into the ruby/bigdecimal project, and is failing to compile on a platform which doesnt have __has_include support in the compiler.

Compile log can be found in this comment:
ruby/bigdecimal#531 (comment)

The very thing the conditional for `__has_include` is trying to handle, is causing compilation to break.

This file was brought into the ruby/bigdecimal project, and is failing to compile on a platform which doesnt have `__has_include` support in the compiler.

Compile log can be found in this comment:
ruby/bigdecimal#531 (comment)
@zenspider zenspider requested a review from jhawthorn April 28, 2026 21:03
@zenspider
Copy link
Copy Markdown
Member

This should be ported over to bigdecimal and any other libs that might use this file.

@nobu
Copy link
Copy Markdown
Member

nobu commented Apr 30, 2026

What compiler and environment?

@darkain
Copy link
Copy Markdown
Author

darkain commented Apr 30, 2026

@nobu This is on Oracle Linux 7.9

@nobu
Copy link
Copy Markdown
Member

nobu commented May 1, 2026

Thank you.
What is the exact compiler version?

I found that the default compiler on Oracle Linux 7 is gcc 4.8.5, but it is too old.
I think you install a newer version.

@darkain
Copy link
Copy Markdown
Author

darkain commented May 1, 2026

The specific check in the code that I'm submitting this PR for is explicitly a fix for "old compilers" that wasn't done correctly. Its the only thing that prevents the code from working on these systems.

@tompng
Copy link
Copy Markdown
Member

tompng commented May 4, 2026

GCC 5 supports __has_include, so your GCC version is 4.8.5 ~ 4.9.4. Ruby >= 3.3 dropped support of GCC <= 6 (https://bugs.ruby-lang.org/issues/19353), and 3.2 is already EOL. So the code is correct for the oldest supported GCC version in the oldest supported Ruby version.

It's unacceptable to merge this as a fix, but I think it's OK as a refactor if it's refactored.

Comparing empty-if and elif vs 3-depth nested if, it's hard to say that it's clearly improved. Can you change the 3-depth nested if to 2-depth nested if like this?

#if !defined(HAVE_STDCKDINT_H) && defined(__has_include)
#if __has_include(<stdckdint.h>)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants