I have a package with C code and a call to int checkInterrupt();
but devtools::check()
says warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
.
How can I call the check interrupt function to pass that warning? I was thinking about checkInterrupt(void *dummy)
but that doesn't work.
checkInterrupt
? You, or a third-party library, or your embedded OS, or what? Theoretically, you should introduce a proper prototype for it by #including the appropriate header file, not by hand-coding an external function declaration in each/every .c file where you use it. (That's almost as error-prone as not using prototypes at all.) – DominecacheckInterrupt
actually takes, and add those in the()
. Don't just guess — that's much worse than not using prototypes at all! (And, by the way,void *
does not mean "anything".) – Domineca#include <R.h>
), and it's a function with no arguments – Astrakhanint checkInterrupt();
is not a function call — it is a declaration of a function returning anint
but without a defined argument list (but it isn't a variadic function likeprintf()
— its prototype would not end with, ...
). And if you compile with-Wstrict-prototypes
, such declarations are not allowed precisely because they don't define a prototype for the function. If the function takes no arguments, say so:extern int checkInterrupt(void);
. And define it asint checkInterrupt(void) { … }
too! (GCC options:-Wold-style-definition
and-Wold-style-declaration
). – Hauck(void)
as the parameter list, and the declaration will provide a prototype for the function. – Hauck#include <R.h>
, you don't need the lineint checkInterrupt();
at all, and you can delete it, and that should make the warning go away. – DominecacheckInterrupt();
(no type before it). That calls the function with no arguments. As long as it has been declared before it is called, all will be well. Maybe you should check the returned value, though — it probably has some significance and maybe your code should respond to that. – Hauckmain
will become a dynamic function, in that it changes at run-time based on whether it is declaredmain()
ormain(int argc, char **argv)
? – Okemain()
and must support bothint main(void)
andint main(int argc, char **argv)
(or equivalents) and may support other implementation-defined signatures. One such variation is listed in Annex J.3 (Common extensions). See also What shouldmain()
return in C and C++? – Hauckmain()
means an undefined number of arguments, so its compatible with the one where you put arguments in. I guess I don't really understand why()
means undefined number of arguments in first place and what the use case for it is, since I had thought that themain()
function was the primary use-case. – Oke