Vscode-cpptools: request to support sdcc mcs51 declarations (__sfr, __sbit, etc)

Created on 8 Sep 2018  路  12Comments  路  Source: microsoft/vscode-cpptools

sdcc, which is quite popular open-source, free embedded compiler, uses special extensions for intel 8051 (aka mcs51) define special function registers and other similar things (like code, ram space, etc)
e.g.

__sfr __at (0xC0) P4   ;
__sbit __at (0xC0) P4_0 ;

extensions are discussed further in section 3.5.1 of sdcc user guide:
http://sdcc.sourceforge.net/doc/sdccman.pdf

We are using sdcc for a new platformio intel-mcs51 platform, (https://github.com/platformio/platform-intel_mcs51) and would _love_ to be able to use the vscode cpptools intellisense here to peek at register definitions, etc.

I see this was previously discussed and rejected for keil C51 compiler at #1821, however I think this is quite different in that Keil is closed/proprietary/non-free (and has it's own ide) whereas sdcc is completely free and opensource, and sdcc+platformio+vscode+cpptools are getting really close to making full open-source ide stack

tagging a few stakeholders:
@ivankravets @spth @znhocn

Feature Request Language Service Visual Studio embedded

Most helpful comment

I've filed a feature request on VS (if they add support, we would probably get it too due to shared code): https://developercommunity.visualstudio.com/idea/1122536/c-intellisense-request-to-support-sdcc-mcs51-decla.html

All 12 comments

Vote

Probably, STM8 interrupt case falls here too. ISR is declared this way:
void tim4_isr(void) __interrupt(ITC_IRQ_TIM4_OVF)
vscode expects { instead of __interrupt.

Similar, for SDCC STM8

void TrapHandler (void) __trap {
...
}

Hi, I would vote for the same thing. It doesn't need to be MCS51 specific; since __sfr and __at are also used in other platforms (at least, I'm using them in Z80/HD64180/Z180).

I would really appreciate this support, I am programming for SDCC and if I use void IRQHandler __interrupt() { }, it then messes up the whole document error checking.

My workaround for this is to edit .vscode/c_cpp_properties.json and edit the"defines"array so that intellisense thinks that the additional keywords are pre-processor defines. Something like:

...
"defines": ["__interrupt(IntelliSense_Hack)=", ...],
...

When you mouseover __interrupt(nn) in your actual code, you will see some garbage tooltip of
"#define __interrupt(IntelliSense_Hack)" but that's only assumed by vscode and not by sdcc / your actual compiler, so the code compiles correctly.

I've filed a feature request on VS (if they add support, we would probably get it too due to shared code): https://developercommunity.visualstudio.com/idea/1122536/c-intellisense-request-to-support-sdcc-mcs51-decla.html

Nothing new ?

@ipa64 The issue at https://developercommunity.visualstudio.com/idea/1122536/c-intellisense-request-to-support-sdcc-mcs51-decla.html needs more upvotes...unfortunately, we don't have a way to link upvotes on GitHub to developer community upvotes.

If more people could upvote https://developercommunity.visualstudio.com/idea/869998/enable-vs-code-users-with-github-accounts-to-upvot.html then maybe they'd figure out a way to make it easier for GitHub votes to get tracked in VS issues.

Thank you @sean-mcmanus
I upvoted here and on your both vsCode requests

I think I have SOLVED.
Just #include "C:/Program Files/SDCC/include/mcs51/lint.h" and everything is wonderful =D
If you have C:/Program Files/SDCC/** or something like that on the includePath (.vscode/c_cpp_properties.json file) you can simply use #include "mcs51/lint.h".

Edit:
Of course, you still have to include the header for your uC, like #include <8052.h>

Was this page helpful?
0 / 5 - 0 ratings

Related issues

montery8 picture montery8  路  3Comments

peterwoods1 picture peterwoods1  路  3Comments

chrisckc picture chrisckc  路  3Comments

ismadelgad11 picture ismadelgad11  路  3Comments

vicatcu picture vicatcu  路  3Comments