Thank you for all who have answered my questions !! seriously thank you. 
The solutions has been found:



#include <8052.h>

#define RELAY P1_4
#define K1 P2_7

main()
{
while(1)
{
  if (!K1) RELAY = 0;
  else RELAY = 1;
}
}


Thank you everybody !!!




Best Regards



On Sat, Jun 8, 2013 at 12:54 AM, Frieder Ferlemann <frieder.ferlemann@web.de> wrote:
Hi JIA Pei,

Am 07.06.2013 12:29, schrieb JIA Pei:
> To whom it may concern:
>
> I kept obtaining the following error message
> *error 2: Initializer element is not constant*

That is because P1^4 is not constant: Port1 XOR 4
(according to C standard) is not known at compile time.

> while building the following code using *MCU8051IDE*, from Compiler configuration, *MCU8051IDE *adopts *--std-sdcc89* .
>
> #include <reg51.h>
> sbit RELAY = P1^4;

Have a look at line 110 of reg51.h to see how it
could be done with the ancient file reg51.h.

Maybe also have a look at section
3.4.1 MCS51/DS390 Storage Class Language Extensions
and finally at one of the more modern header files
(which use #include <compiler.h>) (like cc2530.h)
to see how header files can be written so that they
can be used with different compilers.

Greetings,
Frieder

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
sdcc-devel mailing list
sdcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-devel



--

Pei JIA

Email: jp4work@gmail.com
cell:    +1 604-362-5816

Welcome to Vision Open
http://www.visionopen.com