Patchwork Fix compilation on GCC 4.5

login
register
mail settings
Submitter Søren Sandmann
Date Oct. 4, 2012, 4:31 a.m.
Message ID <ye8ipaqj1s7.fsf@llama10.cs.au.dk>
Download mbox | patch
Permalink /patch/189017/
State New
Headers show

Comments

Søren Sandmann - Oct. 4, 2012, 4:31 a.m.
Richard Henderson <rth@twiddle.net> writes:

>> diff --git a/osdep.h b/osdep.h
>> index cb213e0..df89552 100644
>> --- a/osdep.h
>> +++ b/osdep.h
>> @@ -41,8 +41,9 @@ typedef signed int              int_fast16_t;
>>  #endif
>>  
>>  /* Convert from a base type to a parent type, with compile time checking.  */
>> -#ifdef __GNUC__
>> -#define DO_UPCAST(type, field, dev) ( __extension__ ( { \
>> +#if defined (__GNUC__) && \
>> +    (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5))
>> +#define DO_UPCAST(type, field, dev) ( __extension__ ( {	\
>>      char __attribute__((unused)) offset_must_be_zero[ \
>>          -offsetof(type, field)]; \
>>      container_of(dev, type, field);}))
>
> Try moving the attribute to the end of the declaration,
> i.e. just before the semi-colon.

The patch below doesn't make any difference. 

Søren

 #define DO_UPCAST(type, field, dev) container_of(dev, type, field)

Patch

diff --git a/osdep.h b/osdep.h
index cb213e0..1a36c20 100644
--- a/osdep.h
+++ b/osdep.h
@@ -43,8 +43,8 @@  typedef signed int              int_fast16_t;
 /* Convert from a base type to a parent type, with compile time
 checking.  */
 #ifdef __GNUC__
 #define DO_UPCAST(type, field, dev) ( __extension__ ( { \
-    char __attribute__((unused)) offset_must_be_zero[ \
-        -offsetof(type, field)]; \
+    char offset_must_be_zero[ \
+        -offsetof(type, field)] __attribute__((unused)) ; \
     container_of(dev, type, field);}))
 #else