From: <sba...@us...> - 2015-05-13 21:29:27
|
Revision: 5257 http://sourceforge.net/p/fuse-emulator/code/5257 Author: sbaldovi Date: 2015-05-13 21:29:24 +0000 (Wed, 13 May 2015) Log Message: ----------- Fix ARRAY_SIZE when using a modern GCC with strict C89 syntax. Modified Paths: -------------- trunk/libspectrum/hacking/ChangeLog trunk/libspectrum/internals.h Modified: trunk/libspectrum/hacking/ChangeLog =================================================================== --- trunk/libspectrum/hacking/ChangeLog 2015-05-13 21:26:38 UTC (rev 5256) +++ trunk/libspectrum/hacking/ChangeLog 2015-05-13 21:29:24 UTC (rev 5257) @@ -1012,3 +1012,5 @@ platform doesn't have pkg-config installed (Sergio). 20150512 pzx_read.c,szx.c,tzx_write.c: avoid mixing declarations and code for C89 compilers (Adrien Destugues) +20150513 internals.h: fix ARRAY_SIZE when using a modern GCC with strict C89 + syntax (Sergio). Modified: trunk/libspectrum/internals.h =================================================================== --- trunk/libspectrum/internals.h 2015-05-13 21:26:38 UTC (rev 5256) +++ trunk/libspectrum/internals.h 2015-05-13 21:29:24 UTC (rev 5257) @@ -63,14 +63,14 @@ #define BUILD_BUG_ON_ZERO(e) \ (sizeof(struct { int:-!!(e) * 1234; })) -#if GNUC_PREREQ(3, 1) +#if !GNUC_PREREQ(3, 1) || defined( __STRICT_ANSI__ ) + #define MUST_BE_ARRAY(a) \ + BUILD_BUG_ON_ZERO(sizeof(a) % sizeof(*a)) +#else #define SAME_TYPE(a, b) \ __builtin_types_compatible_p(typeof(a), typeof(b)) #define MUST_BE_ARRAY(a) \ BUILD_BUG_ON_ZERO(SAME_TYPE((a), &(*a))) -#else - #define MUST_BE_ARRAY(a) \ - BUILD_BUG_ON_ZERO(sizeof(a) % sizeof(*a)) #endif #define ARRAY_SIZE(a) ( \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |