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
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.
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.