Reference: http://tsroad.lofter.com/post/376316_57ac519
1.GNU C defines a 0-length array, which is intended to define variable-length structures.
struct VAR_STRUCT
{
int Len;
Char data[0];
};
The data of this structure is immediately followed and can be accessed using Data[index].
2.case can range match, case x...y
Switch (n)
{
Case 0...9 C=1;break;
Case 10...11 C=2;break;
...
}
3.GNU c the statement in curly braces as an expression that can appear where any expression can appear
#define Int_min (x, y) \
{int __x= (x); int __y= (y); __x<__y?__x:__y;}
4.typeof keyword, you can get the type of the variable
int x;
typeof (x) y;
5. Macros that support variable parameters
#define DPRINT (Fmt,arg ...) \
PRINTK (fmt,# #arg)
6. Current function name, using macro __function__
7. When initializing a struct or array, the initialization values are allowed to appear in any order by index and struct name.
int s[5]={[0 ... 3]=3,[4]=1};
Note [0 spaces ... Space 3]
struct X
{
int A;
Char b;
};
struct x y=
{
. b= ' h ',
. a=10,
};
8. Allows the declaration of functions, variables, types of special properties, as long as the following add __atribute__ ((attribute))
#define Attri_noreturn __attribute__ ((noreturn))
void exit () Attri_noreturn
{
...
}
9.GNU C provides a large number of built-in functions
10. Use the Do ... while (0) to define the macro to facilitate the addition of the macro;
#define XXX Do{free (p);p =null;} while (0)
11. Error handling is often done with goto statements.
The above is from "Linux device driver development details".
The difference between GNU C and ANSI C