1

I'm writing a test harness for some C modules, one of which contains the "sbit" keyword. The code was initially written for the Keil C51 compiler, where sbit is used to define a bit within an sfr, more information here. However, I'm writing the test harness using GCC, where sbit isn't defined. I've tried every combination of static, const, int, and bool, none of which seem to satisfy the compiler. #define doesn't work either, because these variables are assigned values further down in the code.

There was a similar question on this site that suggested that sbit might be too low level for GCC. In any case, is there something I can do to get around this?

Andy
  • 21
  • 2
  • I am not sure I understand your question. Is `typedef unsigned short sbit;` what you are looking for? – jxh Jun 11 '14 at 18:26
  • GCC won't understand `sbit` since it is a Keil extension. You might be able to work something out with GCC inline assembly: http://gcc.gnu.org/onlinedocs/gcc/Using-Assembly-Language-with-C.html – markgz Jun 11 '14 at 18:32
  • @jxh- just FYI, Keil sbit addresses an individual _bit_ in a special function register. – DoxyLover Jun 11 '14 at 18:34
  • 1
    @Andy- AFAIK, gcc does not support the 8051 so I'm assuming you're porting to gcc for _another_ processor. No other processor will have the same SFRs as an 8051 so you'll need to rewrite these modules anyway. – DoxyLover Jun 11 '14 at 18:36

0 Answers0