Fecha: febrero 20, 2023
Autor: Guillermo Garcia
Categorías: Visual Studio Code Etiquetas: Development tools
In the previous article, Visual Studio Code for ARM with CMake #5 VSC Tasks, we added the files to create tasks to automate the compilation processes.
In this article, we will configure the IntelliSense extension, which is an essential tool when using Visual Studio Code for cross-compiling.
Table of Contents
Cross-compiling is a feature of compilers that allows them to generate executable code for a different platform than the one on which the compiler is running.
With the development environment in Visual Studio Code, we are performing cross-compiling thanks to the ARM GCC compiler.
Visual Studio Code does not inherently recognize the language features. To enhance this capability in the code editor, we use the IntelliSense extension.
The extension provides features such as syntax highlighting, data type highlighting, and function and library inclusion definitions.
It is necessary to provide configuration settings. These settings are established through a file called c_cpp_properties.json.
We will create this file in the .vscode directory. In this file, we will include the paths to the directories that contain the inclusion files, along with other configurations.
Let’s look at the contents of the c_cpp_properties.json file.
{ "configurations": [ { "name": "ARM none eabi GCC", "includePath": [ "${workspaceFolder}/main", "${workspaceFolder}/CMSIS/Include", "${workspaceFolder}/CMSIS/Device/ST/STM32G0xx", "${workspaceFolder}/Device", "${workspaceFolder}/Drivers/Inc", "${workspaceFolder}/Drivers/Inc/Legacy" ], "defines": [ "STM32G071xx", "USE_HAL_DRIVER" ], "compilerPath": "${config:SetPathToolchainARM}/arm-none-eabi-gcc.exe", "cStandard": "c17", "cppStandard": "c++17", "intelliSenseMode": "gcc-arm" } ], "version": 4 }
In the includePath section, we will list the paths to all directories containing inclusion files.
To highlight code sections with preprocessor statements, we place the definitions in the defines section.
In compilerPath, we specify the path to the compiler executable. Here, we use the variable ${config:SetPathToolchainARM}
, which we defined in the settings.json file.
Let’s see how Visual Studio Code behaves when we don’t have the configuration file for IntelliSense.
We see how it doesn’t recognize certain definitions in source code files.
When we add the c_cpp_properties.json configuration file we see how the extension begins to perform its function by exploring all the content of our project.
Now we can navigate between the definitions by Ctrl + click.
Deja una respuesta