On 07.11.2010 05:02, Federico G. Benavento wrote: > the syntax (){} is for structures, like (Point){0, 0} or something, > so you don't need the braces there, just the cast > > .writearr = (const unsigned char*)JEDEC_WREN, >
writearr should point to a one-member const unsigned char array, and the zeroth element of that array has the value JEDEC_WREN. Your suggested code has different behaviour (it casts a uchar to uchar *): #include <stddef.h> #include <stdio.h> #define JEDEC_WREN 0x06 struct spi_command { const unsigned char *writearr; }; int main(int argc, char *argv[]) { struct spi_command cmds[] = { { .writearr = (const unsigned char[]){ JEDEC_WREN }, },{ .writearr = (const unsigned char *)JEDEC_WREN, }}; printf("Mine: writearr=%p\n", cmds[0].writearr); printf("Mine: writearr[0]=0x%02hhx\n", cmds[0].writearr[0]); printf("Federico: writearr=%p\n", cmds[1].writearr); printf("Federico: writearr[0]=0x%02hhx\n", cmds[1].writearr[0]); return 0; } Output is: Mine: writearr=0xbf8eb213 Mine: writearr[0]=0x06 Federico: writearr=0x6 Segmentation fault Regards, Carl-Daniel -- http://www.hailfinger.org/