Skip to content

Fix K&R-style function declarations in rand.h incompatible with GCC 1…#1

Merged
greatfireball merged 1 commit into
masterfrom
remove-k-n-r-style-function
May 20, 2026
Merged

Fix K&R-style function declarations in rand.h incompatible with GCC 1…#1
greatfireball merged 1 commit into
masterfrom
remove-k-n-r-style-function

Conversation

@greatfireball
Copy link
Copy Markdown
Owner

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 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).

…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).
@greatfireball greatfireball merged commit ca36ccc into master May 20, 2026
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.

libsession-token-perl: ftbfs with GCC-15 error: too many arguments to function ‘isaac’ + ‘randinit’

1 participant