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,



On Sat, Nov 6, 2010 at 9:56 PM, Carl-Daniel Hailfinger
<[email protected]> wrote:
> Hi,
>
> any idea why the code below causes an error message from pcc? I'm trying
> to port flashrom to Plan 9, but I've been fighting the compiler for the
> last few hours.
> /usr/glenda/flashrom/test3.c:20[stdin:45] constructor must be a structure
> /usr/glenda/flashrom/test3.c:25[stdin:50] constructor must be a structure
>
> Regards,
> Carl-Daniel
>
> #include <stddef.h>
>
> #define JEDEC_WREN              0x06
> #define JEDEC_WREN_OUTSIZE      0x01
> #define JEDEC_CE_C7             0xc7
> #define JEDEC_CE_C7_OUTSIZE     0x01
>
> struct spi_command {
>        unsigned int writecnt;
>        unsigned int readcnt;
>        const unsigned char *writearr;
>        unsigned char *readarr;
> };
>
> void spi_chip_erase_c7(void)
> {
>        struct spi_command cmds[] = {
>        {
>                .writecnt       = JEDEC_WREN_OUTSIZE,
>                .writearr       = (const unsigned char[]){ JEDEC_WREN },
>                .readcnt        = 0,
>                .readarr        = NULL,
>        }, {
>                .writecnt       = JEDEC_CE_C7_OUTSIZE,
>                .writearr       = (const unsigned char[]){ JEDEC_CE_C7 },
>                .readcnt        = 0,
>                .readarr        = NULL,
>        }, {
>                .writecnt       = 0,
>                .writearr       = NULL,
>                .readcnt        = 0,
>                .readarr        = NULL,
>        }};
> }
>
>
>
>



-- 
Federico G. Benavento

Reply via email to