我该如何教有关__fp16的Visual Studio Code?

问题描述

我有一个用arm-none-eabi编译器编译的Cortex-M4F微控制器的makefile项目,并且我将__fp16存储类型用于某些浮点数。我正在使用Visual Studio Code编辑代码,并使用makefile进行编译。

我的代码可以很好地编译,但是Visual Studio Code无法识别__fp16存储类型。

Enter image description here

我正在使用c_cpp_properties.json配置编译器和compile_commands.json。

{
    "configurations": [
        {
            "name": "Mac","includePath": [
                "${workspaceFolder}/**","${workspaceFolder}/../**","/usr/local/FreeRTOSv10.2.0/FreeRTOS/**"
            ],"defines": [
                "DEBUG=1","FIRMWARE_VERSION=\"DUMMY\""
            ],"compilerPath": "/usr/local/bin/gcc-arm-none-eabi-8-2018-q4-major/bin/arm-none-eabi-gcc","compilerArgs": [
                "-mcpu=cortex-m4","-march=armv7+fp","-mfpu=fpv4-sp-d16","-mfloat-abi=hard","-mfp16-format=ieee"
            ],"intelliSenseMode": "gcc-arm","cStandard": "c11","compileCommands": "${workspaceFolder}/compile_commands.json"
        }
    ],"version": 4
}

如何教授有关__fp16存储类型的Visual Studio代码?我以为它会通过compilerArgs设置和-mfp16-format=ieee参数来发现类型,但似乎没有什么不同(我在这里尝试过各种组合...)。

解决方法

这看起来像是Intellisense错误。 Intellisense会在您键入时快速编译代码,只是为了捕获简单的错误。但这不是完整的GCC编译器。 Intellisense不会生成ARM代码,它只会检查合法的C ++。

您可以通过向__fp16=float中的defines添加c_cpp_properties.json来愚弄Intellisense。如果documentation是正确的,则不传递给实际的编译器,而传递给Intellisense。