Skip to content

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

Open
greatfireball wants to merge 1 commit into
hoytech:masterfrom
greatfireball:remove-k-n-r-style-function
Open

Fix K&R-style function declarations in rand.h incompatible with GCC 1…#7
greatfireball wants to merge 1 commit into
hoytech:masterfrom
greatfireball:remove-k-n-r-style-function

Conversation

@greatfireball

Copy link
Copy Markdown

Fixes #5
Fixes #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).
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