Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix make error for Fedora 42 #1741

Merged
merged 1 commit into from
Feb 2, 2025
Merged

Conversation

michaelortmann
Copy link
Member

@michaelortmann michaelortmann commented Jan 17, 2025

Found by: robert-scheck
Patch by: michaelortmann
Fixes: #1740

One-line summary:
Add -std=gnu99, if available, to CFLAGS

Additional description (if needed):
GCC 15 changes the default language version for C compilation from -std=gnu17 to -std=gnu23. See https://gcc.gnu.org/gcc-15/changes.html

Please run misc/runautotools when merging this PR.

Test cases demonstrating functionality (if applicable):
Test with gcc-15-20250112
Before:

/home/michael/opt/gcc-15-20250112/bin/gcc -g -O2 -pipe -Wall -I.. -I..  -DHAVE_CONFIG_H -I/usr/include  -c botcmd.c
botcmd.c: In function ‘bot_filereq’:
botcmd.c:1155:9: error: too many arguments to function ‘f’; expected 0, have 3
 1155 |         f(idx, from, path);
      |         ^ ~~~
make[1]: *** [Makefile:86: botcmd.o] Error 1
make[1]: Leaving directory '/home/michael/projects/eggdrop/src'
make: *** [Makefile:243: eggdrop] Error 2

After:
/home/michael/opt/gcc-15-20250112/bin/gcc -std=gnu99 -g -O2 -pipe -Wall -I.. -I.. -DHAVE_CONFIG_H -I/usr/include -c botcmd.c

@vanosg vanosg added this to the v1.10.1 milestone Jan 20, 2025
@vanosg vanosg merged commit 1ad1eaf into eggheads:develop Feb 2, 2025
24 checks passed
@robert-scheck
Copy link

Wouldn't the real fix have been to correct the prototype of f() instead of adding a compiler flag to suppress this?

@thommey
Copy link
Member

thommey commented Feb 2, 2025

We rely on the f() syntax to specify a function with unspecified arguments. That is perfectly legal until and including C17. Eggdrop in general follows POSIX 2001 and C99 with GNU extensions. I believe it is the correct solution to specify what coding standard we use on the commandline (gnu99) and I was surprised we don't yet do that.
Otherwise, like in this instance, compilers changing their default can break our code if the standards aren't compatible, we don't want that.

I am confused by the attempt to make C23 saner by introducing f() = f(void) so late in the game, I would prefer to avoid C over these breaking language changes.

Update: The justification for the change was given as (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm):

Function declarators without prototypes have been an obsolescent feature since the very first ISO C standard. 33 years of advance warning should be enough.

Hard to argue with that, I was under the impression it was legal and supported. In any case, we would have to rewrite a massive portion of our codebase (as we use f() as a generic function prototype for the module API) - @michaelortmann started with that at first, but that is simply too much change in a legacy codebase with little test coverage IMHO.

@michaelortmann michaelortmann deleted the gnu99 branch February 3, 2025 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

botcmd.c:1155:9: error: too many arguments to function ‘f’; expected 0, have 3
4 participants