From c5ad90c93dafa8203e3d88562cd6e01f247cb063 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Thu, 23 Jan 2025 12:18:47 -0800 Subject: [PATCH] device_mmio: Fixed initialization of anonymous union on legacy compilers An anonymous union is a feature of the C language which allows a union declared within a struct to be declared without a name: struct foo { union { int a; char b; }; }; A struct containing an anonymous union may be initialized in either of the following ways: /* Form A */ struct foo test = { .a = 1234 }; /* Form B */ struct foo test2 = { { .a = 1234 } }; Before the release of C11 (which became available in GCC 4.7.1), anonymous unions were only supported by GNU extensions to the C language: GNU89 or GNU99. Support for Form A of anonymous union initialization was added in GCC 4.6.1. Older version only support Form B of the above example. This patch improves compatiblity with legacy versions of GCC by converting an instance of anonymous struct initialization from Form A to Form B. Signed-off-by: Joel Holdsworth --- include/zephyr/sys/device_mmio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zephyr/sys/device_mmio.h b/include/zephyr/sys/device_mmio.h index e6971c96ebed..4beebfc96aa4 100644 --- a/include/zephyr/sys/device_mmio.h +++ b/include/zephyr/sys/device_mmio.h @@ -264,7 +264,7 @@ struct z_device_mmio_rom { * @param node_id DTS node_id */ #define DEVICE_MMIO_ROM_INIT(node_id) \ - ._mmio = Z_DEVICE_MMIO_ROM_INITIALIZER(node_id) + { ._mmio = Z_DEVICE_MMIO_ROM_INITIALIZER(node_id) } /** * @def DEVICE_MMIO_MAP(device, flags)