Skip to content

Commit dbc2d64

Browse files
authored
Merge pull request #605 from ruby/fix-compiler-error-c23
Fix compilation error with C23
2 parents d9c6fdc + df35321 commit dbc2d64

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

ext/json/ext/generator/generator.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@
66

77
#include "ruby.h"
88

9-
#ifdef HAVE_STDBOOL_H
10-
#include <stdbool.h>
11-
#else
12-
/* This is the fallback definition from Ruby 3.0.5. */
13-
typedef unsigned char _Bool
14-
#define bool _Bool
9+
/* This is the fallback definition from Ruby 3.4 */
10+
#ifndef RBIMPL_STDBOOL_H
11+
#if defined(__cplusplus)
12+
# if defined(HAVE_STDBOOL_H) && (__cplusplus >= 201103L)
13+
# include <cstdbool>
14+
# endif
15+
#elif defined(HAVE_STDBOOL_H)
16+
# include <stdbool.h>
17+
#elif !defined(HAVE__BOOL)
18+
typedef unsigned char _Bool;
19+
# define bool _Bool
20+
# define true ((_Bool)+1)
21+
# define false ((_Bool)+0)
22+
# define __bool_true_false_are_defined
23+
#endif
1524
#endif
1625

1726
#ifdef HAVE_RUBY_RE_H

0 commit comments

Comments
 (0)