#include <8051.h>
#define RELAY P1_4 #define K1 P2_7 void main() { if (!K1) RELAY = 0; else RELAY = 1; } Albert W dniu 2013-06-07 12:29:50 użytkownik JIA Pei <jp4w...@gmail.com> napisał: To whom it may concern: I kept obtaining the following error message error 2: Initializer element is not constant while building the following code using MCU8051IDE, from Compiler configuration,MCU8051IDEadopts--std-sdcc89 . 1) Code A #include <reg51.h> sbit RELAY = P1^4; sbit K1 = P2^7; main() { if (!K1) RELAY = 0; else RELAY = 1; } Clearly, sdcc89 is not keil C, which is fantastic ! However, it seems if I modify the above code and change it into 1) Code B #include <reg51.h> main() { sbit RELAY = P1^4; sbit K1 = P2^7; if (!K1) RELAY = 0; else RELAY = 1; } the above code B can be successfully built. However, after I did hex->binand flash the .bin file into my board, the board doesn't work at all. However, by buildingcode A and flashing the .hex file usingPZ-ISP under Windows, the board works fine. So, is there any suggestions by using sdcc? How can I make the code both built and work successfully by compiling with sdcc? Thank you very much. ------------------------------------------------------------------------------ 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-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user