0

Why does the following piece of code compile error free?

#include <stdio.h>
main(aaa) { // <-- This argument is what I consider rubbish
    printf("hello, world\n");
}

I am just trying to define main() with random rubbish and see what error a compiler(gcc version 4.9.2 (Debian 4.9.2-10)) throws up.

user1720897
  • 1,216
  • 3
  • 12
  • 27
  • That should answer your question. – 2501 Jul 04 '16 at 07:43
  • 2
    This is because GCC before version 5.0 defaults to the gnu90 standard, which is C90 + non-standard extensions. C90 allowed "implicit int". Details about the allowed forms of main can be found [here](http://stackoverflow.com/a/31263079/584518). – Lundin Jul 04 '16 at 07:44
  • @2501 Actually I'm not sure if that duplicate answers the question, because it is not clear why `int main (int)` would be an acceptable form of main. One would have to refer to some GCC document describing the allowed implementation-defined forms of main. – Lundin Jul 04 '16 at 07:57
  • main can be implementation defined as anything according to the Standard anyway. – 2501 Jul 04 '16 at 08:01
  • @2501 Only if the compiler documents it. If the compiler allows a special kind of main, and it is not documented, then the compiler is not conforming. – Lundin Jul 04 '16 at 08:47

0 Answers0