views:

116

answers:

5

You can put a link to comparison matrix or lists of extensions available to main compilers. If none of this is available, you could write a list of extension you use or like in your favorite compiler.

+2  A: 

Well, this depends on whether you mean C89 or C99 when you say "ANSI C". Since most mainstream implementations aren't fully C99-compliant yet, I'm going to assume C89.

In that case, I'd say (and not including specific APIs like POSIX or BSD Sockets):

  • long long must be the most common extension;
  • followed by allowing accesses to union members other than the last written;
  • inline is probably up there;
  • snprintf is available in a lot of places;
  • allowing casting between function pointers and void pointers is widespread;
  • alloca

Edit: Ahh yes, how could I forget the ubiquitous // style comment.

caf
I am thinking on the last available, then C99. I think almost/all additions on C99 are based on extensions to C89, so they become ANSI and dropped the extension "label". Surely if an extension to C89 didn't get ANSI specification, it still an extension to C99.
bigown
C99 was written by ISO rather than ANSI. ANSI then ratified it, but even so "ANSI C" more commonly means C89 in my experience, because the name stuck before C99 existed. Perhaps it was considered at the time a bit weird to start calling C99 "ANSI C" when it was designed by an ISO working group, not an ANSI working group, and hence is "less ANSI" than C89. Or perhaps it's influenced mainly by gcc's -ansi option.
Steve Jessop
+1  A: 

In one of the notorious compilers for embedded C, you can specify little- or big-endian for a struct type independently from the processor's preference. Very convenient for writing device drivers, if you remember not to access one of the fields through (say) an int* that forgets the endianness.

Are you serious with the feature matrix thing? Do you think SO members have nothing better to do?

Pascal Cuoq
+1  A: 

A number of compilers allow anonymous structs inside anonymous unions, which is useful for some things, e.g.:

struct vector3
{
    union
    {
        struct
        {
            float x, y, z;
        };
        float v[3];
    };
};

// members can now be accessed by name or by index:
vector3 v;
v.x = 1.0f; v.y = 2.0f; v.z = 3.0f;
v.v[0] = v.v[1] = v.v[2] = 0.0f;
Adam Rosenfield
+4  A: 

C++/ISO-C style comments by far: //

aib