Bug #22184
closederror: conflicting types for ‘OnigUChar’; have ‘char16_t’ {aka ‘short unsigned int’} since
Description
This issue was found at Rails Nightly CI https://buildkite.com/rails/rails-nightly/builds/4522#019f393b-4212-453f-8f4f-c1a538af23e5/L3911
Steps to reproduce¶
- Install these packages (this repro uses Ubuntu 26.04)
- Create extconf.rb and repro.c
- extconf.rb
- repro.c
- Run
ruby.extconf & make
Expected behavior¶
It should pass like:
Actual behavior¶
It raises the error: conflicting types for ‘OnigUChar’; have ‘char16_t’ {aka ‘short unsigned int’}
$ ruby extconf.rb
creating Makefile
$ make
compiling repro.c
In file included from /home/yahonda/.local/share/mise/installs/ruby/trunk/include/ruby-4.1.0+4/ruby/internal/core/rregexp.h:30,
from /home/yahonda/.local/share/mise/installs/ruby/trunk/include/ruby-4.1.0+4/ruby/internal/core.h:31,
from /home/yahonda/.local/share/mise/installs/ruby/trunk/include/ruby-4.1.0+4/ruby/ruby.h:29,
from /home/yahonda/.local/share/mise/installs/ruby/trunk/include/ruby-4.1.0+4/ruby.h:38,
from repro.c:1:
/home/yahonda/.local/share/mise/installs/ruby/trunk/include/ruby-4.1.0+4/ruby/onigmo.h:76:16: error: conflicting types for ‘OnigUChar’; have ‘char16_t’ {aka ‘short unsigned int’}
76 | # define UChar OnigUChar
| ^~~~~~~~~
/home/yahonda/.local/share/mise/installs/ruby/trunk/include/ruby-4.1.0+4/ruby/onigmo.h:79:24: note: previous declaration of ‘OnigUChar’ with type ‘OnigUChar’ {aka ‘unsigned char’}
79 | typedef unsigned char OnigUChar;
| ^~~~~~~~~
make: *** [Makefile:251: repro.o] Error 1
$
Workaround¶
Setting CPPFLAGS=-DONIG_ESCAPE_UCHAR_COLLISION workarounds this error.
$ ruby -v
ruby 4.1.0dev (2026-07-07T04:45:34Z master 86a6b79e5d) +PRISM [x86_64-linux]
yahonda@myubuntu:~/src/github.com/yahonda/ruby-head-uchar-repro$ ruby extconf.rb
creating Makefile
$ make CPPFLAGS=-DONIG_ESCAPE_UCHAR_COLLISION
compiling repro.c
linking shared-object repro.so
$
Reference https://github.com/rails/buildkite-config/pull/187
Updated by byroot (Jean Boussier) 19 days ago
- Assignee set to byroot (Jean Boussier)
Thank you for the report, I will try to find a way to embed T_REGEXP without including onigmo.h (no idea how at this point).
Updated by byroot (Jean Boussier) 19 days ago
Potential fix: https://github.com/ruby/ruby/pull/17701
Updated by byroot (Jean Boussier) 19 days ago
- Status changed from Open to Closed
Applied in changeset git|0fd945f3de57af984cb1cfb14dfe144ece61951c.
Stop including onigmo.h in rregexp.h
Followup: https://github.com/ruby/ruby/pull/17671
[Bug #22184]
onigmo.h contains a lot of declarations that can easily
conflict with third party code, hence it's better to keep
it opaque. That however requires a few hacks.