portability of "designated initializers" - Mailing list pgsql-hackers

From Alvaro Herrera
Subject portability of "designated initializers"
Date
Msg-id 20081122231029.GF3813@alvh.no-ip.org
Whole thread Raw
Responses Re: portability of "designated initializers"  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

I wonder how portable designated initializers are.  As far as I can tell
they were only defined in C99.  Can we use them in our source?  If not,
is there a way to do this in C89?

I mean something like this:

typedef struct foo {       char    type;       union {               int     ival;               float   fval;       }
val;
} foo;

static foo foos[2] = {       {                      .type = 'i',               .val.ival = 42       } , {
  .type = 'f',               .val.fval = 2.78       }
 
};


-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Minor race-condition problem during database startup
Next
From: David Fetter
Date:
Subject: Re: Cool hack with recursive queries