Fix K&R-style function declarations in rand.h incompatible with GCC 1…#1
Merged
Merged
Conversation
…4+ (C23)
GCC 14 changed the default C standard to C23, which redefines the meaning
of empty parameter lists. In C23, `void func()` is equivalent to
`void func(void)` — a function that takes no arguments.
The declarations in rand.h used a technique of hiding parameters inside
comments to make them invisible to the compiler:
void randinit(/*_ randctx *r, word flag _*/);
void isaac(/*_ randctx *r _*/);
The C preprocessor strips comments before compilation, leaving:
void randinit();
void isaac();
Under C23 this means "takes no arguments", which conflicts with the actual
function definitions that do take parameters, causing a type mismatch and
breaking the build with:
error: conflicting types for 'isaac'
This patch replaces the comment-hidden parameters with explicit declarations:
void randinit(randctx *r, word flag);
void isaac(randctx *r);
Fixes build failure on GCC 14+ (e.g. Alpine Linux 3.23, Debian Trixie).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes hoytech#5
Fixes hoytech#6
GCC 14 changed the default C standard to C23, which redefines the meaning of empty parameter lists. In C23,
void func()is equivalent tovoid func(void)— a function that takes no arguments.The declarations in rand.h used a technique of hiding parameters inside comments to make them invisible to the compiler:
The C preprocessor strips comments before compilation, leaving:
Under C23 this means "takes no arguments", which conflicts with the actual function definitions that do take parameters, causing a type mismatch and breaking the build with:
This patch replaces the comment-hidden parameters with explicit declarations:
Fixes build failure on GCC 14+ (e.g. Alpine Linux 3.23, Debian Trixie).