Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Range initialisers are a gcc extension. They should not be used in portable code.


Any time I have ever, ever used a gcc extension in my own code, I have always been sorry for having done so later --- usually more than a year later, at a moment when I don't really have time budgeted for being sorry about binding my code directly to gcc.

(I see a difference between literally using GCC-dialect C and relying on dubious C constructs that happen to work well on C; for instance, I've never been bitten by "extern inline").


'extern inline' isn't a dubious C99 construct; it's well defined what it means.

The problem is that the 'extern inline' gcc extension means something else, and is enabled by default unless you specify -std=c99


I agree your code should not depend on GCC, but stuff like __attribute__((nonnull(1), format(printf, 3, 4))) - "the first argument may not be NULL, the third argument is a printf()-style format string with arguments starting after the fourth element" - can produce some useful warnings and can be trivially disabled on non-GCC compilers. Some of the most useful extensions don't lock you into GCC.

(Now, if only Microsoft would get off their asses and make their compiler C99-compliant, we could all write much nicer code.)


I have run into errors caused by weird uses of inline, I think it was with the MIPSpro compiler, in code happily swallowed by gcc.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: