Electronic – __bit in the XC8 C compiler

mplabxpicxc8

Let's take an example:

extern volatile __bit TRISB0 @ (((unsigned) &TRISB)*8) + 0;

I believe this is pointing TRISB0 to the appropriate bit address. But I don't understand why __bit is used instead of bit, the XC8 data type.

I've tried to find an explanation for __bit in the XC8 User's Guide and elsewhere, but to no avail.

Best Answer

It's right there in the user guide in black and white...

bit and __bit are exactly the same, except for the level of compatibility:

If the xc8 flag --STRICT is used, the bit keyword becomes unavailable, but you can use the __bit keyword.

So you can use bit for your own data type, variable name, function name, whatever you want, if you specify --STRICT on the command line, and still use __bit to specify a bit.

The --STRICT option is used to enable strict ANSI C conformance of all special, non-standard keywords. The MPLAB XC8 C compiler supports various special keywords (for example the persistent type qualifier). If the --STRICT option is used, these keywords are changed to include two underscore characters at the beginning of the keyword (for example, __persistent) so as to strictly conform to the ANSI standard. Thus if you use this option, you will need to use the qualifier __persistent in your code, not persistent.