From c86f045ff1b9f7c0a49f020cbd70cf863bf83499 Mon Sep 17 00:00:00 2001 From: Tim Haines Date: Mon, 2 Mar 2026 15:32:39 -0600 Subject: [PATCH] Fix flexible array members in event_t, HWC_Set_t Since C99, flexible array members have been required to be the last member of a structure type. 6.7.2.1 Structure and union specifiers Constraints (16) As a special case, the last element of a structure with more than one named member may have an incomplete array type; this is called a flexible array member. --- src/common/record.h | 6 +++--- src/tracer/hwc/common_hwc.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/record.h b/src/common/record.h index 53e3a34a..d4833738 100644 --- a/src/common/record.h +++ b/src/common/record.h @@ -78,13 +78,13 @@ typedef struct u_param param; /* Parameters of this event */ UINT64 value; /* Value of this event */ UINT64 time; /* Timestamp of this event */ -#if 1 || USE_HARDWARE_COUNTERS || defined(HETEROGENEOUS_SUPPORT) - long long HWCValues[MAX_HWC]; /* Hardware counters read for this event */ -#endif INT32 event; /* Type of this event */ #if 1 || USE_HARDWARE_COUNTERS || defined(HETEROGENEOUS_SUPPORT) INT32 HWCReadSet; /* Marks which set of counters was read, if any */ #endif +#if 1 || USE_HARDWARE_COUNTERS || defined(HETEROGENEOUS_SUPPORT) + long long HWCValues[MAX_HWC]; /* Hardware counters read for this event */ +#endif } event_t; diff --git a/src/tracer/hwc/common_hwc.h b/src/tracer/hwc/common_hwc.h index a10a6f7d..a8467f85 100644 --- a/src/tracer/hwc/common_hwc.h +++ b/src/tracer/hwc/common_hwc.h @@ -42,7 +42,6 @@ struct HWC_Set_t pm_prog_t pmprog; int group; #endif - int counters[MAX_HWC]; int num_counters; unsigned long long change_at; enum ChangeType_t change_type; @@ -51,6 +50,7 @@ struct HWC_Set_t int *OverflowCounter; int NumOverflows; #endif + int counters[MAX_HWC]; }; // Define a safe default if PAPI is not available