Does any one know how to create an unnamed variable for place holder in a struct? I know you can do it in bitfiled. Example:
struct S { int a; int b; int[5]; //reserved 5 ints but dont' need to name it. int c; int d; int bit0 : 1; int : 6; int bit7 : 1; } </pre?
Implicit in my previous post was the suggestion that you use a standard format; eg, call them all reserved_xxx, where xxx is just a 3-digit (or whatever) number. Using a fixed 3 (or whatever) digits means that a simple text sort (eg, as in the uVision browser) will put them in the right order - otherwise you get reserved_9 coming before reserved_199 in a sorted list! Also, a fixed size makes it easier to construct a regular expression to find them all
If your objective is simply to avoid the drudgery of typing 'reserved' structure member names, this short AWK script will do it for you:
BEGIN { FS = "[" } /[ \t]+(char|short|int|long)\[/ { count_str = sprintf("%03d", count++) $0 = $1 " reserved_" count_str "[" $2 } {print}
struct S { int a; int b; int[5]; //reserved 5 ints but dont' need to name it. char[5]; //reserved 5 ints but dont' need to name it. long[5]; //reserved 5 ints but dont' need to name it. int[5]; //reserved 5 ints but dont' need to name it. int c; int d; int bit0 : 1; int : 6; int bit7 : 1; }
struct S { int a; int b; int reserved_000[5]; //reserved 5 ints but dont' need to name it. char reserved_001[5]; //reserved 5 ints but dont' need to name it. long reserved_002[5]; //reserved 5 ints but dont' need to name it. int reserved_003[5]; //reserved 5 ints but dont' need to name it. int c; int d; int bit0 : 1; int : 6; int bit7 : 1; }