Re:Main is usually a function, so when is it not? (2015)
by _kst_ on Monday June 14, 2021 @04:36PM
(#27507963)
The C standard requires main to be defined as a function, but failure to do so is not a constraint violation, so no diagnostic is required. If you define it as something else, the behavior is undefined.
A conforming C compiler could reject a program that defines main as an array, but is not required to do so.
gcc doesn't complain by default, but with warning enabled it says "warning: 'main' is usually a function".
A conforming C compiler could reject a program that defines main as an array, but is not required to do so.
gcc doesn't complain by default, but with warning enabled it says "warning: 'main' is usually a function".