int main(void) pedantry [Was Re: bfin c++ problem]
Thu Jul 21 17:17:00 GMT 2016
On 21 July 2016 at 16:16, Oliver Kullmann wrote:
>> > That is rather unclear, unfortunately.
>> > The question is what "the type" means.
>> The type of the function. It's entirely clear, give up.
> that's now an argument?
>> > As far as I am aware, 8.3.5 only *mentions* the "equivalence of types",
>> > but does not say where this is applicable.
>> int main(void) and int main() declare the same function. It has the
>> same type, because it's the same function.
> You won't find this in the standard.
Are you drunk?
> Which is a problem!
> Being involved with the "safety-and-security" industry, I can see the
> enormous problems caused by such "standards". Nevertheless, the C++
> standard has an important social role.
C++14 8.3.5 [dcl.fct] p4 (C++14): If the parameter-declaration-clause
is empty, the function takes no arguments. A parameter list consisting
of a single unnamed parameter of non-dependent type void is equivalent
to an empty parameter list.
So f(void) also means a function that takes no arguments.
You can quibble about the meaning of "equivalent" but it has the usual
English meaning. int main() and int main(void) are equivalent
declarations. They are interchangeable. They mean the same thing.
Since nothing in the standard says anything about the meaning of
f(void) except that it's equivalent to f(), it takes some serious
"imagination" to interpret that as meaning it's actually something
subtly different. But something that the standard omits to mention.
Maybe to keep language lawyers in business.
Or, you can interpret it sensibly: The only wording on the subject
says it's equivalent. It doesn't talk about "the equivalence of types"
it says f(void) is equivalent to f().
If you want to play a language lawyer on the internet pick a sensible topic.
More information about the Gcc-help