Closed MilanKlausz closed 7 months ago
Are you actually sure that we also get compilation errors with the empty parameter lists? Because those I imagine we have a whole bunch of, and honestly the int foo(void)
form is damn ugly.
Yes, the error messages are quite explicit e.g.:
/Users/milanklausz/dgcode_val/.bld/pkgs/MCPL/libsrc/mcpl.c:223:39: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
void mcpl_platform_compatibility_check() {
^
void
I even read somewhere that in the backgroung "int foo()" is actually using the K&R-style function definition syntax (with an empty identifier lists), not an empty parameter list, but I can't find the reference now. Here is another source, though: "The special case of an unnamed parameter of type void as the only item in the list specifies that the function has no parameters."
Ok, got it! In that case I will update the functions with no arguments in ncrystaldev / .. / ncrystal.h as well.
However, I hope that this does not apply to argument-less functions in C++ code inside extern "C"
blocks!
To answer myself: I think argument-less functions in C++ code inside extern "C"
blocks must be fine, because it is still C++ in that file!
I guess we can close this now.
After upgrading to XCode 14.3 (requires macOS Ventura 13.0 or later), I get a lot of compillation errors (warnings treated as errors) saying "A function declaration without a prototype is deprecated in all versions of C". This is because "C2x will be removing support for functions with identifier lists, and will be changing the behavior of prototypeless functions with empty parentheses to match the behavior of C++" (from link)
A lot of functions in MiniZLib use the now unsupported identifier lists (a part of K&R-style function definition syntax). The errors/warnings could be silenced by using _DG_EXTRACFLAGS=-Wno-strict-prototypes compillation flag (as suggested in https://github.com/madler/zlib/issues/633 ), but for us it would be better to change the function definitions:
to
Also, for similar reason, empty parameter lists should be given an explicit parameter of void:
to