I was recently porting a project from GCC to clang(in which I fixed a number of C GNU-isms). This got me thinking: what C GNU-isms(extensions to the C language supported in GCC, which are not standardized) exist? Is there a comprehensive list anywhere?
Here is a pretty comprehensive list straight from GCC's website. There seems to be quite a lot, so I wish you the best of luck sifting through it!
http://gcc.gnu.org/onlinedocs/gcc-4.2.0/gcc/C-Extensions.html
One of the nicest GNUisms I found was explicit key declaration while filling structures.
struct canmsg_t {
short flags;
int cob;
canmsg_id_t id;
unsigned long timestamp;
unsigned int length;
unsigned char data[CAN_MSG_LENGTH];
};
canmsg_t msg =
{
["flags"] = 0x00;
["cob"] = 0;
["id"] = 0x534;
["timestamp"] = 0;
["length"] = 1;
["data"] = { 0 };
}
This does not allow to skip members or reorder them, just throws an error if you do so, but with 100+ element structures this becomes invaluable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With