main function ?

why in Keil compiler we define the main as int rather that void ?

int main (void)

rather than ....

void main (void) ,like in C51

Parents
  • You are approaching this from the wrong direction!

    The ANSI standard states that main() returns an int result - so you should rather be asking why C51 violates that requirement.

    The 8051 is a small, simple processor and is very likely to be used in systems that are very tightly constrained on code and memory space - therefore anything that gives any unnecessary overhead needs to be removed.
    Also, C51 has a very long history, dating back to times when these constraints were even more pressing - hence it was doubly important to remove any unnecessary bloat.

    None of this is true for the ARM itself or the Realview compiler - so there is no real reason for it to flout the requirements of the ANSI specification.

Reply
  • You are approaching this from the wrong direction!

    The ANSI standard states that main() returns an int result - so you should rather be asking why C51 violates that requirement.

    The 8051 is a small, simple processor and is very likely to be used in systems that are very tightly constrained on code and memory space - therefore anything that gives any unnecessary overhead needs to be removed.
    Also, C51 has a very long history, dating back to times when these constraints were even more pressing - hence it was doubly important to remove any unnecessary bloat.

    None of this is true for the ARM itself or the Realview compiler - so there is no real reason for it to flout the requirements of the ANSI specification.

Children
More questions in this forum