I am reading an old book about code obfuscation in C (the book was printed in 1993), and I’ve noticed that the functions with arguments are implemented this way:
real_dump(address, infunc, ofp)
char *address;
int (*infunc)();
FILE *ofp;
{
/* the code goes here... */
}
Also, no return type is defined.
Is it an old standard? Is it possible to enable gcc to compile this code?
Function definitions in the non-prototype form are valid C89, C99 and C11 code.
It is called the old-style function definition but this feature is marked since C89 as an obsolescent feature.
This form should be not used in new programs.
C99 Rationale says:
even K&R2 discourages its use:
Now your function also doesn’t have a return type and omitting the return type in a function declaration or in a function definition is no longer valid since C99. Before C99, functions without a return type implicitely returned an
int.Regarding the
gccquestion, by defaultgcccompiles with-std=gnu89. It means C89 Standard + gcc extensions. So by defaultgccwill accept to compile a program with the functions declaration and definition in their old-style form and without a return type.