This article will show  how to use Visual Studio Code’s Include Paths for C/C++ to assist ARM programming. While writing code, Visual Studio Code with the C/C++ plugin has a number of handy features:

  • Highlighting of syntax
  • We check for errors as we type, and
  • Automatic code completion, in which it makes educated predictions as we type.

This can help us write more quickly and with fewer errors. These capabilities, however, will not work well or at all if the plugin is not properly configured.

Visual Studio Code and the C/C++ language plugin need to be able to locate all of the header files referenced in our programme in order to understand it.

The lightbulb to the left of the error will be seen if the pointer is on it. Then update the “includePath” setting by clicking that. In our project, VSCode will generate and open a file called “c cpp properties.json” in the “.vscode” folder. This will have setups for Mac, Linux, and Win32 by default. These include default includePaths that are appropriate for desktop programmes but unsuitable for ARM.

There are two paths in this area. The first, “includePath,” tells VSCode where to look for headers so it can examine our code. This is not recursive, unlike GCC; we must explicitly identify each folder containing headers that are referenced, either directly or indirectly.

The second section with just “path” is used by IntelliSense to suggest things for us.This is the initial c_cpp_properties.json file:

{
    "configurations": [
        {
            "name": "WIN32",
            "includePath": [
                "${workspaceFolder}/**",
                "E:\\ti\\TivaWare_C_Series-2.2.0.295"
            ],
            "defines": [
                "_DEBUG",
                "PART_TM4C123GH6PM"
            ],
            "compilerPath": "C:\\ProgramData\\chocolatey\\bin\\arm-none-eabi-gcc",
            "cStandard": "c99",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "gcc-arm",
            "configurationProvider": "ms-vscode.cmake-tools"
        },
        {
            "name": "LINUX",
            "includePath": [
                "${workspaceFolder}/**",
                "/home/jshankar/ti/TivaWare_C_Series-2.2.0.295"
            ],
            "defines": [
                "_DEBUG",
                "PART_TM4C123GH6PM"
            ],
            "compilerPath": "/opt/toolchains/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gcc",
            "cStandard": "c99",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "gcc-arm",
            "configurationProvider": "ms-vscode.cmake-tools"
        }        
    ],
    "version": 4
}
  • name: arbitrary name for the configuration
  • includePath: list here all locations where IntelliSense shall search for header files. It automatically will use the ones located in the toolchain (compiler) installation. The ‘**’ notation means it will search recursively that folder
  • defines: list all the extra defines which shall be considered.
  • forcedInclude: if using the -include compiler option, make sure you list that file here
  • compilerPath: path to the compiler executable.
  • cStandard and cppStandard: the C and C++ standard to be used
  • intelliSenseMode: mode to be used. ‘gcc-arm’ is considered legacy, but not sure what to use otherwise for ARM?
Author

Write A Comment