Re: Function call before main.
Richard wrote:
> Eric Sosman <esosman@ieee-dot-org.invalid> writes:
>
>> Richard wrote:
>>> santosh <santosh.k83@gmail.com> writes:
>>>
>>>> Srinu wrote:
....
>>>>> int f();
>>>> To state explicitly that the function takes no parameters use the `void`
>>>> keyword.
>>> What does "f()" state?
>> Do you truly not know? I thought you'd been on this
>> newsgroup long enough to have seen this mentioned half a
>> dozen times, but perhaps that's a different "Richard."
>
> Nope. Probably me. And I never knew that. I had always assumed it to be
> a lazy definition of f(void), but since I have never used it (I cant
> remember the last time I wrote a function without at least one
> parameter) then I wasn't sure.
>
>> It states that the function f takes some fixed number
>
> Or doesn't state :-;
Well, it is undefined behavior to call f() with a different number of
arguments than the number specified in the definition of f(), or if the
definition of f() makes it a variadic function. So this declaration does
indeed state that the number is fixed.
>> of arguments, but does not state what that number is nor
>> what the types of the arguments are.
>
> Which is used where?
It's only supported to allow compilation of code written before the
invention of proper function prototypes. It serves no good purpose that
is not better served by a function prototype. It can be used to
obfuscate code, if that's your desire.
|