Skip to content

Commit 3ebfeb5

Browse files
authored
Merge pull request #164 from yinqiwu/master
Redefine __attribute__, solve the problem of compilation in IAR envir…
2 parents 794f047 + 7e96ab1 commit 3ebfeb5

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) \
@@ -464,7 +480,7 @@ typedef struct {
464480
// page header, part of each page except object lookup pages
465481
// NB: this is always aligned when the data page is an object index,
466482
// as in this case struct spiffs_page_object_ix is used
467-
typedef struct __attribute(( packed )) {
483+
typedef struct SPIFFS_PACKED {
468484
// object id
469485
spiffs_obj_id obj_id;
470486
// object span index
@@ -474,7 +490,7 @@ typedef struct __attribute(( packed )) {
474490
} spiffs_page_header;
475491

476492
// object index header page header
477-
typedef struct __attribute(( packed ))
493+
typedef struct SPIFFS_PACKED
478494
#if SPIFFS_ALIGNED_OBJECT_INDEX_TABLES
479495
__attribute(( aligned(sizeof(spiffs_page_ix)) ))
480496
#endif
@@ -496,7 +512,7 @@ typedef struct __attribute(( packed ))
496512
} spiffs_page_object_ix_header;
497513

498514
// object index page header
499-
typedef struct __attribute(( packed )) {
515+
typedef struct SPIFFS_PACKED {
500516
spiffs_page_header p_hdr;
501517
u8_t _align[4 - ((sizeof(spiffs_page_header)&3)==0 ? 4 : (sizeof(spiffs_page_header)&3))];
502518
} spiffs_page_object_ix;

0 commit comments

Comments
 (0)