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

Don't use old-style unprototyped C functions #11764

Merged
merged 3 commits into from
Nov 28, 2022

Conversation

MisterDA
Copy link
Contributor

Fixes strict-prototypes and old-style-definition warnings. As a reminder, f() declares f as an old-style function that can be applied to any number of arguments.

Subsumes and closes #11762.

Note: I've just noticed that I haven't enabled the warnings on mingw, so I haven't checked the prototypes on Windows only code yet.

@MisterDA
Copy link
Contributor Author

Yes, there are more occurrences that I hadn't caught. Please give me a couple of minutes ;)

@xavierleroy
Copy link
Contributor

Take your time :-)

@MisterDA
Copy link
Contributor Author

If all is right, #11763 should show that this PR fixes all old-style prototypes on Linux, macOS and Windows since it adds warnings to catch them.
I've also had to remove K&R C style function definitions from Windows code in otherlibs/unix.

@MisterDA MisterDA changed the title Declare functions with no arguments as f(void), not f() Don't use old-style C function prototypes Nov 28, 2022
@shindere
Copy link
Contributor

shindere commented Nov 28, 2022 via email

@xavierleroy xavierleroy changed the title Don't use old-style C function prototypes Don't use old-style unprototyped C functions Nov 28, 2022
Copy link
Contributor

@xavierleroy xavierleroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks a lot! Just to make sure, I'm running a round of CI precheck to get feedback on all Windows ports. Will merge afterwards.

Fixes strict-prototypes and old-style-definition warnings. As a
reminder, `f()` declares `f` as an old-style function that can be
applied to any number of arguments.
Fixes strict-prototypes and old-style-definition warnings.
@MisterDA
Copy link
Contributor Author

I've just force-pushed and applied this that I had forgotten:

diff --git a/testsuite/tests/asmgen/mainarith.c b/testsuite/tests/asmgen/mainarith.c
index ae4d1c50e0..fce523767a 100644
--- a/testsuite/tests/asmgen/mainarith.c
+++ b/testsuite/tests/asmgen/mainarith.c
@@ -22,7 +22,7 @@
 #include <caml/config.h>
 #define FMT ARCH_INTNAT_PRINTF_FORMAT

-void caml_call_poll()
+void caml_call_poll(void)
 {
 }

@xavierleroy xavierleroy merged commit 026ce3a into ocaml:trunk Nov 28, 2022
@xavierleroy
Copy link
Contributor

CI precheck was happy, so I added a Changes entry and merged.

@MisterDA MisterDA deleted the missing-prototypes branch November 28, 2022 18:35
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.

3 participants