From fed3a951cd96ee4343de1fb557a09bdf33fcb530 Mon Sep 17 00:00:00 2001 From: "resver@gmail.com" Date: Thu, 13 Jun 2013 18:06:18 +0000 Subject: [PATCH] Modified STATIC_ASSERT so that it can be used both inside and outside of functions. git-svn-id: http://exfat.googlecode.com/svn/trunk@360 60bc1c72-a15a-11de-b98f-4500b42dc123 --- libexfat/compiler.h | 3 +-- libexfat/exfatfs.h | 16 ++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libexfat/compiler.h b/libexfat/compiler.h index 4a5ca80..45e8581 100644 --- a/libexfat/compiler.h +++ b/libexfat/compiler.h @@ -43,7 +43,6 @@ #define CONCAT2(a, b) a ## b #define CONCAT1(a, b) CONCAT2(a, b) #define STATIC_ASSERT(cond) \ - static inline void CONCAT1(static_assert, __LINE__)(void) \ - {switch (0) {case 0: case cond:;}} + extern void CONCAT1(static_assert, __LINE__)(int x[(cond) ? 1 : -1]) #endif /* ifndef COMPILER_H_INCLUDED */ diff --git a/libexfat/exfatfs.h b/libexfat/exfatfs.h index d2e95e3..9e36c89 100644 --- a/libexfat/exfatfs.h +++ b/libexfat/exfatfs.h @@ -63,7 +63,7 @@ struct exfat_super_block le16_t boot_signature; /* the value of 0xAA55 */ } PACKED; -STATIC_ASSERT(sizeof(struct exfat_super_block) == 512) +STATIC_ASSERT(sizeof(struct exfat_super_block) == 512); #define EXFAT_ENTRY_VALID 0x80 #define EXFAT_ENTRY_CONTINUED 0x40 @@ -81,7 +81,7 @@ struct exfat_entry /* common container for all entries */ uint8_t data[31]; } PACKED; -STATIC_ASSERT(sizeof(struct exfat_entry) == 32) +STATIC_ASSERT(sizeof(struct exfat_entry) == 32); #define EXFAT_ENAME_MAX 15 @@ -93,7 +93,7 @@ struct exfat_entry_bitmap /* allocated clusters bitmap */ le64_t size; /* in bytes */ } PACKED; -STATIC_ASSERT(sizeof(struct exfat_entry_bitmap) == 32) +STATIC_ASSERT(sizeof(struct exfat_entry_bitmap) == 32); struct exfat_entry_upcase /* upper case translation table */ { @@ -105,7 +105,7 @@ struct exfat_entry_upcase /* upper case translation table */ le64_t size; /* in bytes */ } PACKED; -STATIC_ASSERT(sizeof(struct exfat_entry_upcase) == 32) +STATIC_ASSERT(sizeof(struct exfat_entry_upcase) == 32); struct exfat_entry_label /* volume label */ { @@ -114,7 +114,7 @@ struct exfat_entry_label /* volume label */ le16_t name[EXFAT_ENAME_MAX]; /* in UTF-16LE */ } PACKED; -STATIC_ASSERT(sizeof(struct exfat_entry_label) == 32) +STATIC_ASSERT(sizeof(struct exfat_entry_label) == 32); #define EXFAT_ATTRIB_RO 0x01 #define EXFAT_ATTRIB_HIDDEN 0x02 @@ -138,7 +138,7 @@ struct exfat_entry_meta1 /* file or directory info (part 1) */ uint8_t __unknown2[10]; } PACKED; -STATIC_ASSERT(sizeof(struct exfat_entry_meta1) == 32) +STATIC_ASSERT(sizeof(struct exfat_entry_meta1) == 32); #define EXFAT_FLAG_ALWAYS1 (1u << 0) #define EXFAT_FLAG_CONTIGUOUS (1u << 1) @@ -157,7 +157,7 @@ struct exfat_entry_meta2 /* file or directory info (part 2) */ le64_t size; /* in bytes, equals to real_size */ } PACKED; -STATIC_ASSERT(sizeof(struct exfat_entry_meta2) == 32) +STATIC_ASSERT(sizeof(struct exfat_entry_meta2) == 32); struct exfat_entry_name /* file or directory name */ { @@ -166,6 +166,6 @@ struct exfat_entry_name /* file or directory name */ le16_t name[EXFAT_ENAME_MAX]; /* in UTF-16LE */ } PACKED; -STATIC_ASSERT(sizeof(struct exfat_entry_name) == 32) +STATIC_ASSERT(sizeof(struct exfat_entry_name) == 32); #endif /* ifndef EXFATFS_H_INCLUDED */ -- 2.11.0