Skip to content

Instantly share code, notes, and snippets.

@hexeguitar
Last active March 29, 2024 16:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hexeguitar/1ffa147b0c358cb3455879c2baa64c63 to your computer and use it in GitHub Desktop.
Save hexeguitar/1ffa147b0c358cb3455879c2baa64c63 to your computer and use it in GitHub Desktop.
Trick to avoid sdcc (not supported keywords) errors in VScode
#ifndef _VSCODE_SDCC_H
#define _VSCODE_SDCC_H
/*
There is currently no support for sdcc syntax (Intellisense) in VScode.
These defines will limit the number of reported errors due to undecognized
sdcc keywords like __code, __at etc.
The trick is, when editing the code in VScode, the SDCC is not defined,
it happens only at compile time. So we can use the "#ifndef SDCC" condition
to redefine the sdcc keywords as empty and make the errors go away.
When compiling, the SDCC is defined and the below redefinitions will not be
included.
Required only when working in VScode.
*/
#ifndef SDCC
#define __code
#define __xdata
#define __data
#define __pdata
#define __at(x)
#define __sbit
#define __asm
#define __endasm
#define __interrupt
#define __using
#define bool uint8_t // with no SDCC defined, compiler.h will need bool
#endif
#endif // _VSCODE_SDCC_H
@abhra0897
Copy link

Just what I wanted! Thanks for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment