Reputation: 573
I get one program (written for linux originally). I can't understand the syntax of some functions. The functions have no return value type. Let me give one example
add_one_point(xx,yy,zz,index)
float xx,yy,zz;
int index;
{
//the implementation
}
In some functions, the implementations don't return any value, but some really return values. Is this a valid C code? If so, how does c compiler process that?
Thanks in advance! Jogging
Upvotes: 2
Views: 248
Reputation: 20266
You should declare a function not returning any value as returning void
, and in any case the return type should be specified. Your compiler might allow you to compiler a function without return value specified (it will default to int, that is why that code might be/have been working), but a modern compiler will at least issue a warning.
Furthermore, as somebody else already noticed, also the input types are specified in an unusual way (without verifying, I would call it non-standard compliant)
Upvotes: 0
Reputation: 281485
Older versions of C allowed the return type to be omitted, defaulting it to int
.
C99 no longer allows it, so if you compiled under C99 mode, it would fail.
Upvotes: 4