From 7e96ab1ee8201a723414dd314bf6f95df83b6e14 Mon Sep 17 00:00:00 2001 From: bruce Date: Tue, 29 Aug 2017 16:19:39 +0800 Subject: [PATCH] Redefine __attribute__, solve the problem of compilation in IAR environment but --- src/spiffs_nucleus.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/spiffs_nucleus.h b/src/spiffs_nucleus.h index 7d676ee..59fb409 100644 --- a/src/spiffs_nucleus.h +++ b/src/spiffs_nucleus.h @@ -141,6 +141,22 @@ #define SPIFFS_OBJ_ID_DELETED ((spiffs_obj_id)0) #define SPIFFS_OBJ_ID_FREE ((spiffs_obj_id)-1) + + +#if defined(__GNUC__) || defined(__clang__) + /* For GCC and clang */ +#define SPIFFS_PACKED __attribute__((packed)) +#elif defined(__ICCARM__) || defined(__CC_ARM) + /* For IAR ARM and Keil MDK-ARM compilers */ +#define SPIFFS_PACKED + +#else + /* Unknown compiler */ +#define SPIFFS_PACKED +#endif + + + #if SPIFFS_USE_MAGIC #if !SPIFFS_USE_MAGIC_LENGTH #define SPIFFS_MAGIC(fs, bix) \ @@ -455,7 +471,7 @@ typedef struct { // page header, part of each page except object lookup pages // NB: this is always aligned when the data page is an object index, // as in this case struct spiffs_page_object_ix is used -typedef struct __attribute(( packed )) { +typedef struct SPIFFS_PACKED { // object id spiffs_obj_id obj_id; // object span index @@ -465,7 +481,7 @@ typedef struct __attribute(( packed )) { } spiffs_page_header; // object index header page header -typedef struct __attribute(( packed )) +typedef struct SPIFFS_PACKED #if SPIFFS_ALIGNED_OBJECT_INDEX_TABLES __attribute(( aligned(sizeof(spiffs_page_ix)) )) #endif @@ -487,7 +503,7 @@ typedef struct __attribute(( packed )) } spiffs_page_object_ix_header; // object index page header -typedef struct __attribute(( packed )) { +typedef struct SPIFFS_PACKED { spiffs_page_header p_hdr; u8_t _align[4 - ((sizeof(spiffs_page_header)&3)==0 ? 4 : (sizeof(spiffs_page_header)&3))]; } spiffs_page_object_ix;