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)
- First of all, please create an embedded project with VisualGDB. E.g., follow the MSP430 tutorial.
- 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:
- 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:When 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.
- First of all, we need to find out which definition is causing problems. Double-click at the first error:Visual Studio indicates that the error is caused by the sfrb() definition.
- 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“:
- The sfrb() definition contains the __asm__ extension that is unknown to Visual Studio and causes IntelliSense to show errors:
- 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_) #else #define sfrb_(x,x_) volatileunsignedchar x __asm__("__" #x) #define sfrb(x,x_) extern sfrb_(x,x_) #endif
- 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::
- Clicking further at the errors shows that now sfrw() macro is causing the problems:
- 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) #endif
- This fixes all IntelliSense errors:
- As long as you have used the #ifdef _MSC_VER wrapper, the changes do not affect the actual compilation at all.
- Note that you can alternatively disable IntelliSense error reporting by right-clicking in the Error List pane and disabling the “Show IntelliSense Errors” checkbox: