lkml.org 
[lkml]   [2001]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject2.4.10-pre9 min/max raises "const" warnings
Date
try this one:

int a, b, c, d;
d = min( a, min( b, c ));

and you will see a gnu c warning about multiple const qualifiers.
(this might depend on the warning level you drive.)

fix it with this code:

#define min(x,y) ({ \

const typeof(x) _x = (x); \

const typeof(y) _y = (y); \

(void) (&_x == &_y); \

(_x < _y) ? (typeof(x)) _x : (typeof(y)) _y; })

simply the last line has changed towards linux kernel patch-2.4.10-pre9 from
ftp.
the same change should apply for the max() macro.

i am yet not sure if the used "? :" operator set does qualify as
a left-value. maybe this could be another important reason why
return types here should stay identical to input types.

regards AlexS.

PS: i am not subscribed to this list.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:03    [W:0.027 / U:0.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site