Open marshfolx opened 2 years ago
I get the same problem.
My workaround is add a new macro before SDCC
#if defined (__SDCC_SYNTAX_FIX)
#include <stdbool.h>
#include <lint.h>
# warning unrecognized compiler
#define __BIT bool
#define __IDATA
#define __PDATA
#define __XDATA
#define __CODE
#define __REENTRANT
#define SBIT(name, addr, bit) volatile bool name
#define SFR(name, addr) volatile unsigned char name
#define SFRX(addr) (*(unsigned char volatile *)(addr))
#define SFR16X(addr) (*(unsigned char volatile *)(addr))
#define INTERRUPT(name, vector) void name (void)
#define INTERRUPT_USING(name, vector, regnum) void name (void)
#define NOP()
#elif defined (SDCC) || defined (__SDCC)
#define __BIT __bit
#define __IDATA __idata
#define __PDATA __pdata
#define __XDATA __xdata
#define __CODE __code
#define __REENTRANT __reentrant
#define SBIT(name, addr, bit) __sbit __at(addr+bit) name
#define SFR(name, addr) __sfr __at(addr) name
#define SFRX(addr) (*(unsigned char volatile __xdata *)(addr))
#define SFR16X(addr) (*(unsigned int volatile __xdata *)(addr))
#define INTERRUPT(name, vector) void name (void) __interrupt (vector)
#define INTERRUPT_USING(name, vector, regnum) void name (void) __interrupt (vector) __using (regnum)
#define NOP() __asm NOP __endasm
//...
#endif
Then create a separate env for code editing
build_flags =
-D__SDCC_SYNTAX_FIX
-D__CONF_FOSC=36864000UL
-D__CONF_MCU_MODEL=MCU_MODEL_STC8H3K32S2
...
and build/upload with another env.
A simple demonstration:
#include <stdbool.h>
#undef __SDCC_mcs51
#include <lint.h>
#define __SDCC_mcs
#include <8052.h>
#define MAIN_Fosc 16000000uL
#define led P1_0
void delay_ms(unsigned int ms);
void main() {
while (1) {
led = true;
delay_ms(500);
led = false;
delay_ms(500);
}
}
void delay_ms(unsigned int ms) {
unsigned int i;
do {
i = MAIN_Fosc / 13000;
while (--i);
} while (--ms);
}
SDCC related defines, like SDCC and SDCC_mcs51, were added somewhere which causes lint.h is useless.
A simple workaround is undef __SDCC_mcs51 before including lint.h, then re-define it, like:
but this way all the SDCC keyword below will disapear.