VS Code NRF Connect Extension NRF53 C++ Intrinsics Intellisense Problems and Workaround

Hello,

I'm using the PCA100095 NRF5340 development board and developing with the NRF Connect extension for VSCode v2022.3.104.

When attempting to use the CMSIS intrinsics for SIMD instructions with C++ files, Intellisense will not recognize the functions. 

It will recognize them for C files, but not when the project is set up with .cpp files.

Can recreate the problem by creating a new application from sample in VSCode:

- Freestanding

- nRF Connect SDK: 1.91

- Application Template: zephyr/samples/hello_world

With Build configuration:

- Board: nrf5340dk_nrf5340_cpuapp

- No extra CMake arguments

- Debug options not enabled

Rename main.c to main.cpp.

Alter CMakeLists.txt to rename main.c to main.cpp

Then setting up the proj.conf file to have:

CONFIG_CMSIS_DSP=y
CONFIG_NEWLIB_LIBC=y
CONFIG_CPLUSPLUS=y
CONFIG_STD_CPP17=y

To include the DSP library and use C++.

Modify main.cpp to have:

#include <zephyr.h>
#include <sys/printk.h>
#include <arm_math.h>

void main(void)
{
	uint32_t res = __SSUB16(0x0, 0x0);
}

Then Pristine build. The build works fine and for my larger application, I've verified that the intrinsics are working and translating to the assembly properly.

However, intellisense now shows that __SSUB16 is undefined.

To fix this, I have to manually set up the c_cpp_properties.json file in the .vscode folder to have:

{
    "configurations": [
        {
            "name": "GCC-ARM",
            "intelliSenseMode": "gcc-arm",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/Users/bryanh/ncs/v1.9.1/toolchain/opt/arm-none-eabi/include",
                "C:/Users/bryanh/ncs/v1.9.1/zephyr/include",
                "C:/Users/bryanh/ncs/v1.9.1/modules/hal/cmsis/CMSIS/Core/Include",
                "C:/Users/bryanh/ncs/v1.9.1/modules/hal/cmsis/CMSIS/DSP/Include",
                "C:/Users/bryanh/ncs/v1.9.1/modules/hal/cmsis/CMSIS/DSP/PrivateInclude"
            ],
            "defines": [
                "BOARD_PCA10095",
                "ARM_MATH_LOOPUNROLL",
                "CORTEX_USE_FPU=TRUE",
                "NRF53",
                "NRF5340_XXAA_APPLICATION",
                "__ZEPHYR__=1",
                "KERNEL",
                "_DEBUG"
            ],
            "compilerPath": "C:/Users/bryanh/ncs/v1.9.1/toolchain/opt/bin/arm-none-eabi-g++.exe",
            "compilerArgs": [
                "-mcpu=cortex-m33",
                "-mthumb",
                "-mcmse",
                "-mfloat-abi=hard",
                "-mfpu=fpv5-sp-d16"
            ],
            "compileCommands": "${workspaceFolder}/build/compile_commands.json",
            "cStandard": "c17",
            "cppStandard": "c++17",
            // "configurationProvider": "nrf-connect"
        }
    ],
    "version": 4
}

Specifically, commenting out "configurationProvider": "nrf-connect" fixes the problem. I'm not sure why that fixes it, but now I have to manually include the zephyr, nrfx modules, and other files as I use more libraries and modules since I can no longer rely on the extension including them. The good news is at least that the build works.

OS: Windows 10 21H2

VSCode Version: 1.66.2

Parents Reply Children
No Data
Related