Interesting GCC extensions

Adam D. Ruppe destructionator at gmail.com
Mon Sep 28 11:18:46 PDT 2009


On Mon, Sep 28, 2009 at 12:35:05PM -0400, bearophile wrote:
> Beside the known ones, like computed gotos and __builtin_expect(), GCC has other less known extensions, you can find some of them here:
> http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/

I remember this page... did you post it here many months ago?

Anyway:

# define __must_check            __attribute__((warn_unused_result))

That one looks kinda cool, though is mostly redundant since we have throw
exceptions.

> One of them is the Range extension, it seems GCC devs think that 3 points are better after all:

They are fools. What D has kicks ass. I actually used the case .. case in
a program and it was just fantastic.

> Triple points can be used for initializations too:
> int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 };

D's slicing can already do this I believe.

> The Constant detection done with __builtin_constant_p(exp) is what I was asking for in one of my recent posts here. It seems I was "right" again.

Aye, that is cool. We should try to get some traits code together and make
a std.reflection or something to do this stuff.


-- 
Adam D. Ruppe
http://arsdnet.net



More information about the Digitalmars-d mailing list