I am having a simple doubt in C programming language.

In any simple C code snippet, if by mistake suppose i have written intmain() instead of main().

Then it represents what type of error ?

It will not be a lexical error as compiler will correctly make a token for it and it is also not a syntax error clearly.

I think it is a semantic error as in this phase compiler checks with the meaningful statements, scoping, binding, variable not declared, function not declared, any variable declared twice, etc.

But, on the other hand, I also think it as a linker error as in the semantic phase, it can throw a error that function intmain() is not declared and it is been directly used.

Can anyone make this crystal clear that what is the actual error ?

  • 1
    $\begingroup$ I would guess that it would be a linker error only if there was an extern declaration of that symbol beforehand. Otherwise, it would be a semantic error. $\endgroup$ Nov 4, 2016 at 15:30
  • $\begingroup$ @TheodorosChatzigiannakis, I didn't get what u said !! Can you plz elaborate or answer, if possible . $\endgroup$
    – Garrick
    Nov 4, 2016 at 17:48
  • $\begingroup$ @TheodorosChatzigiannakis, Why did you remove your answer ? $\endgroup$
    – Garrick
    Nov 5, 2016 at 2:29
  • $\begingroup$ I realized it wasn't as relevant to the question as I thought when I wrote it. $\endgroup$ Nov 5, 2016 at 7:13

1 Answer 1


We can reproduce your error using this C++ code:

intmain() {
    return 0;

The following error is returned during compile time:

error: ISO C++ forbids declaration of ‘intmain’ with no type [-fpermissive]

Every function in C/C++ has to have a type. In this sense, it's a type error, which falls in the category of (static) semantic errors. On the other hand, your error is caused by a typo. This sort of error is considered a lexical error, which falls under syntax errors.

There is a lot of discussion whether certain errors are syntactical or static semantic. My opinion is this case is that the error is lexical, considering the cause.

  • 3
    $\begingroup$ In C89, function declarations with no type specifiers is allowed however, which implicitly gives the function a return type of int. (See section 3.5.2) This means that depending on which version of the language you're talking about (GCC defaults to C89 even today), this is either a syntax error or a semantic error. In C89, the function intmain() {...} compiles just fine on every version of GCC; it just doesn't have a main symbol. $\endgroup$
    – Lee
    Nov 4, 2016 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.