Re: stringify MAKE_SQLSTATE()

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Subject: Re: stringify MAKE_SQLSTATE()
Date: 2015-07-22 14:20:37
Message-ID: 55AFA6B5.50809@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>> #define MAKE_SQLSTATE(ch1,ch2,ch3,ch4,ch5) \
>> ((char[]){(char)(ch1),(char)(ch2),(char)(ch3),(char)(ch4),(char)(ch5),(char)'\0'})
>
> I'm pretty sure that's a gcc-ism, not standard C.
Hmm, after some digging: the feature is called compound literals and it was
introduced in c99 although gcc has support in c90. To disable this support it's
needed a flag -pedantic. Sorry.

> The real question is do we want to. What's your use-case for this?
Just do not have a hardcoded values. It is too easy to make a mistake in
hardcoded value.

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-07-22 14:29:44 Re: Implementation of global temporary tables?
Previous Message Marti Raudsepp 2015-07-22 14:20:31 Re: [PATCH] pg_upgrade fails when postgres/template1 isn't in default tablespace