Hi!

Following discussion at https://commitfest.postgresql.org/5/190/ patch, I found (at seems to me) a way to stringify MAKE_SQLSTATE(), the idea is to use char array as string:

#include <stdio.h>

#define MAKE_SQLSTATE(ch1,ch2,ch3,ch4,ch5) \

((char[]){(char)(ch1),(char)(ch2),(char)(ch3),(char)(ch4),(char)(ch5),(char)'\0'})

#define ERRCODE_WARNING_DEPRECATED_FEATURE MAKE_SQLSTATE('0','1','P','0','1')

int
main(int argn, char* argv[])
{
    char    *x = ERRCODE_WARNING_DEPRECATED_FEATURE;

    printf("%s\n", x);

    return 0;
}

That works for clang ang gcc48 with flags -Wall -Wextra -ansi (or -std=c90) without warnings, but doesn't work with -pedantic. Is that enough to to work with other compilers?

--
Teodor Sigaev                                   E-mail: teo...@sigaev.ru
                                                   WWW: http://www.sigaev.ru/


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to