I love Visual Studio Code. I’ve been using it for several years now, after migrating from paid JetBrains licenses. Unfortunately, it doesn’t play nice with non-standard C compilers, such as those used for embedded systems or older CPUs.
What happens is that Intellisense will flag non-standard keywords as syntax errors. This will usually cascade into more false errors further down, such as missing variable declarations. For example:
The errors detected on the buffer
and ibuffp
pointers prevent Intellisense from seeing those variables declarations, and so any time they are referenced in the code they are flagged as missing.
The __near
qualifier tells the Calypsi 65816 compiler that this pointer is within the current data bank (as set by the DB register) and can be implemented in just 16 bits. This gives a speed boost to code using those pointers. There are also __tiny
, __far24
, and __far
, which mark pointers as 8-bit (direct page), 24-bit, or 32-bit.
Unfortunately there’s currently no way to extend the syntax in Intellisense (though there is an open feature request for this). Fortunately, there is an easy workaround:
#ifdef __INTELLISENSE__
#define __tiny
#define __near
#define __far
#define __far24
#endif
This block, placed in one of my global headers, just #defines away these keywords inside VSCode Problem solved!