Skip to content

Commit 7e96ab1

Browse files
Redefine __attribute__, solve the problem of compilation in IAR environment but
1 parent fec9999 commit 7e96ab1

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/spiffs_nucleus.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,22 @@
141141
#define SPIFFS_OBJ_ID_DELETED ((spiffs_obj_id)0)
142142
#define SPIFFS_OBJ_ID_FREE ((spiffs_obj_id)-1)
143143

144+
145+
146+
#if defined(__GNUC__) || defined(__clang__)
147+
/* For GCC and clang */
148+
#define SPIFFS_PACKED __attribute__((packed))
149+
#elif defined(__ICCARM__) || defined(__CC_ARM)
150+
/* For IAR ARM and Keil MDK-ARM compilers */
151+
#define SPIFFS_PACKED
152+
153+
#else
154+
/* Unknown compiler */
155+
#define SPIFFS_PACKED
156+
#endif
157+
158+
159+
144160
#if SPIFFS_USE_MAGIC
145161
#if !SPIFFS_USE_MAGIC_LENGTH
146162
#define SPIFFS_MAGIC(fs, bix) \
@@ -455,7 +471,7 @@ typedef struct {
455471
// page header, part of each page except object lookup pages
456472
// NB: this is always aligned when the data page is an object index,
457473
// as in this case struct spiffs_page_object_ix is used
458-
typedef struct __attribute(( packed )) {
474+
typedef struct SPIFFS_PACKED {
459475
// object id
460476
spiffs_obj_id obj_id;
461477
// object span index
@@ -465,7 +481,7 @@ typedef struct __attribute(( packed )) {
465481
} spiffs_page_header;
466482

467483
// object index header page header
468-
typedef struct __attribute(( packed ))
484+
typedef struct SPIFFS_PACKED
469485
#if SPIFFS_ALIGNED_OBJECT_INDEX_TABLES
470486
__attribute(( aligned(sizeof(spiffs_page_ix)) ))
471487
#endif
@@ -487,7 +503,7 @@ typedef struct __attribute(( packed ))
487503
} spiffs_page_object_ix_header;
488504

489505
// object index page header
490-
typedef struct __attribute(( packed )) {
506+
typedef struct SPIFFS_PACKED {
491507
spiffs_page_header p_hdr;
492508
u8_t _align[4 - ((sizeof(spiffs_page_header)&3)==0 ? 4 : (sizeof(spiffs_page_header)&3))];
493509
} spiffs_page_object_ix;

0 commit comments

Comments
 (0)