portability of "designated initializers"

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: portability of "designated initializers"
Date: 2008-11-22 23:10:29
Message-ID: 20081122231029.GF3813@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2008-11-22 23:52:39 Re: Cool hack with recursive queries
Previous Message Simon Riggs 2008-11-22 21:42:19 Re: Review: Hot standby