Skip to content

Commit

Permalink
Fix MEMFAULT_PACKED_ENUM compile failure with IAR
Browse files Browse the repository at this point in the history
Use `__packed enum` instead of `enum __packed` for IAR

Fixes: memfault#87

Signed-off-by: Jason Yu <[email protected]>
  • Loading branch information
zejiang0jason committed Jan 24, 2025
1 parent 03050f2 commit 5af9209
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/include/memfault/core/compiler_armcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extern "C" {
#endif

#define MEMFAULT_PACKED __packed
#define MEMFAULT_PACKED_ENUM enum MEMFAULT_PACKED
#define MEMFAULT_PACKED_STRUCT MEMFAULT_PACKED struct
#define MEMFAULT_NORETURN __declspec(noreturn)
#define MEMFAULT_NAKED_FUNC __asm
Expand Down
1 change: 1 addition & 0 deletions components/include/memfault/core/compiler_gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extern "C" {
#endif

#define MEMFAULT_PACKED __attribute__((packed))
#define MEMFAULT_PACKED_ENUM enum MEMFAULT_PACKED
#define MEMFAULT_PACKED_STRUCT struct MEMFAULT_PACKED
//! MEMFAULT_NORETURN is only intended to be overridden in unit tests, if needed
#if !defined(MEMFAULT_NORETURN)
Expand Down
1 change: 1 addition & 0 deletions components/include/memfault/core/compiler_iar.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern "C" {
#include "intrinsics.h"

#define MEMFAULT_PACKED __packed
#define MEMFAULT_PACKED_ENUM MEMFAULT_PACKED enum
#define MEMFAULT_PACKED_STRUCT MEMFAULT_PACKED struct
#define MEMFAULT_NORETURN __noreturn
#define MEMFAULT_NAKED_FUNC
Expand Down
1 change: 1 addition & 0 deletions components/include/memfault/core/compiler_ti_arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern "C" {
#include <inttypes.h>

#define MEMFAULT_PACKED __attribute__((packed))
#define MEMFAULT_PACKED_ENUM enum MEMFAULT_PACKED
#define MEMFAULT_PACKED_STRUCT struct MEMFAULT_PACKED
#define MEMFAULT_NORETURN __attribute__((noreturn))
#define MEMFAULT_NAKED_FUNC __attribute__((naked))
Expand Down
2 changes: 1 addition & 1 deletion components/include/memfault/core/reboot_reason_types.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern "C" {

//! This enum must be packed to prevent compiler optimizations in instructions which load an
//! eMemfaultRebootReason.
typedef enum MEMFAULT_PACKED MfltResetReason {
typedef MEMFAULT_PACKED_ENUM MfltResetReason {
// A reboot reason was not determined either by hardware or a previously marked reboot reason
// This reason is classified as a crash when calculating the operational_crashfree_hours metric
kMfltRebootReason_Unknown = 0x0000,
Expand Down

0 comments on commit 5af9209

Please sign in to comment.