Fixing IntelliSense errors for MSP430 and other targets

VisualGDB 5.0+ comes with a new Clang-based IntelliSense engine that is fully compatible with GNU language extensions, does not require manual adjustment and supports features like Code Map and refactoring. You can read more about the new engine



The information below is no longer relevant and only applies to older VisualGDB versions that do not include the new IntelliSense engine.

Step-by-step guide (for older VisualGDB versions)

  1. First of all, please create an embedded project with VisualGDB. E.g., follow the MSP430 tutorial.
  2. When the project is created, let Visual Studio parse all header files. If you then see IntelliSense errors related to GCC-specific register definitions like on the screenshot below, this tutorial will explain how to resolve them. For MSP430 targets you will see the following errors:01-err
  3. The errors occur because when you are using VisualGDB, all your source files are processed by 2 independent parsers: Visual Studio IntelliSense parser looks through all files to display function argument and structure hints, while the actual compilation is performed by the GCC compiler:parserWhen the IntelliSense parser encounters a GCC-specific construct, it treats it as an error although it won’t cause any actual compilation problems. The solution is to provide an IntelliSense-friendly definition of problematic GCC-specific definitions and ensure that the actual GCC will ignore that definition.
  4. First of all, we need to find out which definition is causing problems. Double-click at the first error:02-definitionVisual Studio indicates that the error is caused by the sfrb() definition.
  5. Right-click on sfrb and select “Go To Definition”. If this does not work, you can search the GCC directory for all header files containing “define sfrb” or just “sfrb“:03-goto
  6. The sfrb() definition contains the __asm__ extension that is unknown to Visual Studio and causes IntelliSense to show errors: 04-sfrb
  7. The easiest way to fix it is to replace the sfrb_ definition with the following one:
    #ifdef _MSC_VER
    #define sfrb_(x,x_) volatileunsignedchar x
    #define sfrb(x,x_) extern sfrb_(x,x_)
    #define sfrb_(x,x_) volatileunsignedchar x __asm__("__" #x)
    #define sfrb(x,x_) extern sfrb_(x,x_)
  8. This will provide an IntelliSense-compatible definition for Visual Studio and still keep an actual definition for GCC. Once sfrb() is fixed, only 28 out of 97 errors remain::05-sfrb-fixed
  9. Clicking further at the errors shows that now sfrw() macro is causing the problems: 06-sfrw
  10. We could fix it by making a Visual Studio-friendly sfrw() definition, however, instead, we will define a global fix for the __asm__ keyword:
    #ifdef _MSC_VER
    #define __asm__(x)
  11. This fixes all IntelliSense errors:07-globalfix
  12. As long as you have used the #ifdef _MSC_VER wrapper, the changes do not affect the actual compilation at all.
  13. Note that you can alternatively disable IntelliSense error reporting by right-clicking in the Error List pane and disabling the “Show IntelliSense Errors” checkbox:08-disable