Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning "Use of GNU statement expression extension"

I have this Objective-C istruction:

NSRange range = NSMakeRange(i, MIN(a, b));

where a and bare NSUIntegers.

MIN() is the macro defined in the standard NSObjCRuntime.hheader file as:

#if !defined(MIN)
   #define MIN(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; })
#endif

During the compilation, the LLVM Compiler 4.1 highlights my instruction showing the warning: "Use of GNU statement expression extension".

What does this mean? Is it my fault? If yes, how can I fix it? If not, how can I remove the compiler warning?

like image 595
Dev Avatar asked Oct 26 '12 12:10

Dev


3 Answers

Don't use -Wno-gnu, that shuts down too many warnings. Instead, use:

-Wno-gnu-statement-expression
like image 194
Eric Avatar answered Oct 28 '22 23:10

Eric


It’s a late answer, I know, but you can avoid this message by adding -Wno-gnu to your compiler flags.

(In Xcode 5 I believe you can change this by going to your project’s Build Settings and adding -Wno-gnu to the “Other C Flags”, which are in the “Apple LLVM 5.0 – Custom Compiler Flags” section.)

like image 11
bdesham Avatar answered Oct 29 '22 01:10

bdesham


"Statement expressions" is an extension of the GNU C compiler and allows you to execute a group of statements, returning the value of the last statement:

x = ({
    statement1;
    statement2;
    statement3;
});

In the above example, x will have the value returned by statement3.

It is a convenient feature that enables you to have multi-statement macros that can be nested easily into other expressions. It is not, however, defined by any C standard.

like image 11
Blagovest Buyukliev Avatar answered Oct 29 '22 01:10

Blagovest Buyukliev