#include "reg51.h" void main(void) { P1 = 0x00; int a = 0; }
But this can be compiled:
#include "reg51.h" void main(void) { int a = 0; }
And these can be compiled too:
#include "reg51.h" void main(void) { P1 = 0x00; }
#include "reg51.h" void main(void) { int a = 0; P1 = 0x00; }
The C51 compiler basically supports the old ANSI C standard C90 with some extensions for the 8051 architecture.
The C90 standard does not allow defining local variables after executable statements within a function. In C90, the syntax rules require that all declarations within a block must come before any statements.
"P1 = 0x00;" is a statement that generates code, because P1 is already defined. After that, no definition of a local variable is allowed.
The C99 standard would allow to intermix statements and definitions, but the C51 compiler will never support this standard.