Follow

Plan9 C doesn't like void functions with no parameters, how do you satisfy the params not checked error?

· · Web · 2 · 2 · 1

@neauoire A function taking no parameters needs to be explicitly declared as such by giving it the void type parameter.

void fn(void);

@kvik I had no idea until today. I'll be more careful. I have a ton of something(), I don't remember tcc ever complaining, so I never knew.

@neauoire @kvik the lack of

void foo(void);
void foo(void) {}

Is a C-ism that was removed in C++ and iirc it’s a holdover from old C dialects like what you’d see in/pre unix v8 where arguments look like

double
fabs(arg)
double arg;
{...}

it’s a way of explicitly communicating to the compiler that /no args are passed/ since in many/some older compilers it’s okay it /no args are used/ or smth like that

@henesy @neauoire If I'm reading the standard right, (open-std.org/jtc1/sc22/wg14/ww section 6.7.6.3. points 10 and 14) a declaration with an empty parameter type list should mean the same as void fn(...); which means unknown number and types of arguments. Presumably you then could use va_arg facility in its definition.

In any case void fn() and void fn(void) are of different types.

@henesy @neauoire Using void fn() instead of void fn(...) is allowed but discouraged in ANSI C, while the Plan 9 compilers reject it outright.

Sign in to participate in the conversation
Merveilles

Revel in the marvels of the universe. We are a collective of forward-thinking individuals who strive to better ourselves and our surroundings through constant creation. We express ourselves through music, art, games, and writing. We also put great value in play. A warm welcome to any like-minded people who feel these ideals resonate with them.