4 ms·
It's an old gcc extension. Don't use it.
by mansr 15y ago
It's an old gcc extension. Don't use it.
- ajross 15y agoIt's a very useful gcc extension. Use if if you're building with gcc. Standards adherence is all well and good, but there are many problem areas where you can rely on a single compiler (surely others support it too: intel and clang seem like likely suspects).
- tptacek 15y agoThere are standards issues and there are standard issues. In reality, you're probably never going to see a 1's complement machine. Your likelihood of needing to use a piece of code under a compiler other than GCC is deceptively high. Meanwhile, the extensions we tend to think about when we think of GCC aren't subtle things like "can you use // comments in C code". They're constructs that require many additional lines of code to replace. It is a giant pain when you find them, later on, when you need to compile something under Visual C or SunWorks. Your fix to comment syntax isn't going to break code at runtime, but your fix for the missing ellipsis operator definitely can! From bitter experience, I think 'mansr is right on this, and it's worth making an effort not to let GCC extensions creep into your code.
- ajross 15y agoBut like I said, it depends on what the code is. If it's a kernel module, then you'd be silly not to use the gcc extension. Likewise if it's a platform-locked linux or mac thing (Android middleware, maybe). You work in security, where you're expected to port stuff between platforms regularly. Not everyone does. And those extensions are there because someone likes them.
- dap 15y ago> If it's a kernel module, then you'd be silly not to use the gcc extension. Sure, if you're not interested in anyone porting that code to another OS. This happens all the time with drivers -- just because the interface is OS-specific doesn't mean all the code is. > And those extensions are there because someone likes them. That doesn't make it a good idea.
- mansr 15y agoExtensions have occasionally been dropped from gcc, sometimes because of conflicts with updated standards, sometimes for other reasons.