TTroy wrote:
> Andrey Tarasevich wrote:
>
>>TTroy wrote:
>>
>>>For function definitions (not declarations/prototypes), is it
>
> necessary
>
>>>to put void in the emptry braces if the function is to receive no
>>>parameters? Does this turn any error checking off or cause any
>
> other
>
>>>effects?
>>
>>No. In a function _definition_ empty '()' immediately means "no
>
> parameters".
>
>
> Even if I use the empty () definition of a function as the only
> declaration?
Let's get specific: If you write
void f(void) { ... }
void g(void) { f(42); }
.... the compiler is required to issue a diagnostic for the
mismatch between the number of arguments in the call and the
number of parameters in the prototype. But if you write
void f() { ... }
void g(void) { f(42); }
.... the compiler is not required to catch the mistake.
> I also have another question. If I was calling a function and also
> casting values of arguments, does this cast come BEFORE or AFTER the
> automatic conversion caused by the prototype? I guess the question
> applies when there is no prototype - does the case happen before or
> after the promotions?
Before. The cast operator is part of the expression
that calculates the value you provide as an argument, just
like other operators (+, -, ...) that might appear in the
expression. The expression yields a value of some type,
and conversions or promotions occur depending on what that
type is and on what the compiler knows about the function.
The cast has already been applied before this happens.
--