Teodor Sigaev <teodor@sigaev.ru> writes:
> 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:
> #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.
As I mentioned in the other thread, if we wanted to provide string
versions of the ERRCODE macros, the safest way to do it would be
to create a separate header file with defines like
#define ERRCODE_WARNING_DEPRECATED_FEATURE "01P01"
Now that we generate errcodes.h from errcodes.txt anyway, it would
certainly be a trivial extension of the build infrastructure to make
a second header like this.
The real question is do we want to. What's your use-case for this?
regards, tom lane