Skip to content

Commit 2beabfa

Browse files
authored
Merge pull request #3074 from ruby/claude/fix-nullability-pedantic-errors
Don't use Clang nullability qualifiers in strict ISO C mode
2 parents da71a3b + e197225 commit 2beabfa

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

include/rbs/defines.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,13 @@
8787
* Nullability annotations for pointer types.
8888
* Clang supports _Nullable and _Nonnull to indicate whether a pointer may be NULL.
8989
* On other compilers, these expand to nothing.
90+
*
91+
* They are Clang extensions, so a strict ISO C compilation rejects them with
92+
* `-Wnullability-extension`, which is an error under `-pedantic-errors`. Expand
93+
* them to nothing in that case, so that embedders compiling these headers with a
94+
* conforming dialect (`-std=c99` and friends define `__STRICT_ANSI__`) still build.
9095
*/
91-
#ifdef __clang__
96+
#if defined(__clang__) && !defined(__STRICT_ANSI__)
9297
#define RBS_NULLABLE _Nullable
9398
#define RBS_NONNULL _Nonnull
9499
#else

0 commit comments

Comments
 (0)