Skip to content

Error parsing C macro with __attribute__ #10694

Open
@weiqj

Description

@weiqj

Environment

  • OS and Version: Ubuntu 22/04
  • VS Code Version: 1.73.1
  • C/C++ Extension Version: 1.15.0

Bug Summary and Steps to Reproduce

Bug Summary:

Steps to reproduce:

#define BYTE_ALIGNED_TEST( __Declaration__ ) __Declaration__ __attribute__((__packed__))

BYTE_ALIGNED_TEST(
typedef struct test_struct {
	uint16_t    i;
	uint8_t      j;
}) test_struct;

Expected behavior:
The code compiles fine.

But Intellisense reports an error:
[{
"resource": "/home/weiqj/workspace/hornet/src/core/net/cluster_lib/libertas_cluster_base.h",
"owner": "C/C++: IntelliSense",
"code": "79",
"severity": 8,
"message": "expected a type specifier",
"source": "C/C++",
"startLineNumber": 57,
"startColumn": 1,
"endLineNumber": 57,
"endColumn": 18
}]

Configuration and Logs

-------- Diagnostics - 3/16/2023, 8:22:21 PM
Version: 1.15.0
Current Configuration:
{
    "name": "Hornet",
    "includePath": [
        "/opt/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/include/",
        "/home/weiqj/workspace/hornet/src/",
        "/home/weiqj/workspace/hornet/src/FreeRTOS-Kernel/include/*",
        "/home/weiqj/workspace/hornet/src/vendors/nordic/nrf5/*",
        "/home/weiqj/workspace/hornet/src/vendors/nordic/nrf5/freertos-libertas/*",
        "/home/weiqj/workspace/hornet/src/devices/nrf52840/dongle/switch/*",
        "/opt/nRF5_SDK_17.1.0_ddde560/external/freertos/portable/ARM/nrf52/*",
        "/opt/nRF5_SDK_17.1.0_ddde560/external/freertos/portable/CMSIS/nrf52/*",
        "/opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx",
        "/opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk",
        "/opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/hal",
        "/opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/soc",
        "/opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/drivers/src",
        "/opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/drivers/include",
        "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars",
        "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/strerror",
        "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/delay",
        "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/util",
        "/opt/nRF5_SDK_17.1.0_ddde560/components/boards",
        "/opt/nRF5_SDK_17.1.0_ddde560/integration/nrfx",
        "/opt/nRF5_SDK_17.1.0_ddde560/integration/nrfx/legacy",
        "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/queue",
        "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/fifo",
        "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/log",
        "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src",
        "/opt/nRF5_SDK_17.1.0_ddde560/components/drivers_nrf/nrf_soc_nosd",
        "/opt/nRF5_SDK_17.1.0_ddde560/components/toolchain/cmsis/include/*",
        "/home/weiqj/workspace/hornet/*",
        "/home/weiqj/workspace/hornet/src/platform/nordic/nrf52840/dongle"
    ],
    "defines": [
        "__GNUC__",
        "NO_XERCESC",
        "__XTENSA__",
        "HORNET_LIBERTAS_APP_ENGINE_ENABLED=1",
        "HORNET_DEVICE_TYPE=HORNET_ROUTER",
        "LIBERTAS_CLUSTER_LIB_APP_SUPPORT"
    ],
    "compilerPath": "/opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gcc",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "gcc-arm",
    "compilerArgs": [
        "-mfloat-abi=hard"
    ],
    "browse": {
        "path": [
            "/opt/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/include/",
            "/opt/gcc-arm-none-eabi-10.3-2021.10/arm-none-eabi/include/",
            "${workspaceFolder}/src/",
            "${workspaceFolder}/src/FreeRTOS-Kernel/include/*",
            "${workspaceFolder}/src/vendors/nordic/nrf5/*",
            "${workspaceFolder}/src/vendors/nordic/nrf5/freertos-libertas/*",
            "${workspaceFolder}/src/devices/nrf52840/dongle/switch/*",
            "/opt/nRF5_SDK_17.1.0_ddde560/external/freertos/portable/ARM/nrf52/*",
            "/opt/nRF5_SDK_17.1.0_ddde560/external/freertos/portable/CMSIS/nrf52/*",
            "/opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx",
            "/opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk",
            "/opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/hal",
            "/opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/soc",
            "/opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/drivers/src",
            "/opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/drivers/include",
            "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars",
            "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/strerror",
            "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/delay",
            "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/util",
            "/opt/nRF5_SDK_17.1.0_ddde560/components/boards",
            "/opt/nRF5_SDK_17.1.0_ddde560/integration/nrfx",
            "/opt/nRF5_SDK_17.1.0_ddde560/integration/nrfx/legacy",
            "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/queue",
            "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/fifo",
            "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/log",
            "/opt/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src",
            "/opt/nRF5_SDK_17.1.0_ddde560/components/drivers_nrf/nrf_soc_nosd",
            "/opt/nRF5_SDK_17.1.0_ddde560/components/toolchain/cmsis/include/*",
            "${workspaceFolder}/*",
            "${workspaceFolder}/src/platform/nordic/nrf52840/dongle"
        ],
        "limitSymbolsToIncludedHeaders": true
    },
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "rawCompilerPath": "/opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gcc",
    "mergeConfigurations": false
}
Translation Unit Mappings:
[ /home/weiqj/workspace/hornet/src/core/net/cluster_lib/libertas_cluster_impl.c ]:
    /home/weiqj/workspace/hornet/src/core/net/cluster_lib/libertas_cluster_impl.c
    /home/weiqj/workspace/hornet/src/core/net/cluster_lib/libertas_cluster_base.h *
Translation Unit Configurations:
[ /home/weiqj/workspace/hornet/src/core/net/cluster_lib/libertas_cluster_impl.c ]:
    Process ID: 65014
    Memory Usage: 854 MB
    Includes:
        /opt/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/include
        /home/weiqj/workspace/hornet/src
        /home/weiqj/workspace/hornet/src/FreeRTOS-Kernel/include
        /home/weiqj/workspace/hornet/src/vendors/nordic/nrf5
        /home/weiqj/workspace/hornet/src/vendors/nordic/nrf5/freertos-libertas
        /home/weiqj/workspace/hornet/src/devices/nrf52840/dongle/switch
        /opt/nRF5_SDK_17.1.0_ddde560/external/freertos/portable/ARM/nrf52
        /opt/nRF5_SDK_17.1.0_ddde560/external/freertos/portable/CMSIS/nrf52
        /opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx
        /opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk
        /opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/hal
        /opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/soc
        /opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/drivers/src
        /opt/nRF5_SDK_17.1.0_ddde560/modules/nrfx/drivers/include
        /opt/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars
        /opt/nRF5_SDK_17.1.0_ddde560/components/libraries/strerror
        /opt/nRF5_SDK_17.1.0_ddde560/components/libraries/delay
        /opt/nRF5_SDK_17.1.0_ddde560/components/libraries/util
        /opt/nRF5_SDK_17.1.0_ddde560/components/boards
        /opt/nRF5_SDK_17.1.0_ddde560/integration/nrfx
        /opt/nRF5_SDK_17.1.0_ddde560/integration/nrfx/legacy
        /opt/nRF5_SDK_17.1.0_ddde560/components/libraries/queue
        /opt/nRF5_SDK_17.1.0_ddde560/components/libraries/fifo
        /opt/nRF5_SDK_17.1.0_ddde560/components/libraries/log
        /opt/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src
        /opt/nRF5_SDK_17.1.0_ddde560/components/drivers_nrf/nrf_soc_nosd
        /opt/nRF5_SDK_17.1.0_ddde560/components/toolchain/cmsis/include
        /home/weiqj/workspace/hornet
        /home/weiqj/workspace/hornet/src/platform/nordic/nrf52840/dongle
        /usr/include/x86_64-linux-gnu/c++/9
        /usr/include/c++/9
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Defines:
        __GNUC__
        NO_XERCESC
        __XTENSA__
        HORNET_LIBERTAS_APP_ENGINE_ENABLED=1
        HORNET_DEVICE_TYPE=HORNET_ROUTER
        LIBERTAS_CLUSTER_LIB_APP_SUPPORT
    Standard Version: c17
    IntelliSense Mode: linux-gcc-arm
Total Memory Usage: 854 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 15681
Number of files parsed: 6347

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions