Robert P. J. Day wrote:
The range initialization syntax is a GNU extension.On Tue, 16 Jan 2007, Mike Frysinger wrote:On 1/16/07, Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> wrote:drivers/scsi/ipr.c: const u8 zero_sn[IPR_SERIAL_NUM_LEN] = { [0 ... IPR_SERIAL_NUM_LEN-1] = '0' }; where does this "..." range syntax come from? i know gcc supports the *case* range extension, but i don't know where the above *arrray* range syntax comes from.just like it looks ... instead of writing '0' IPR_SERIAL_NUM_LEN times, gcc will fill it for yousorry, i wasn't clear. i wanted to know where that syntax is *defined*. i don't see it in my C99 spec, and it's not listed as a gcc extension. so where did it come from? rday >From http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html: To initialize a range of elements to the same value, write `[first ... last] = value'. This is a GNU extension. For example, int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 }; If the value in it has side-effects, the side-effects will happen only once, not for each initialized field by the range initializer. Note that the length of the array is the highest value specified plus one. |