Re: More CppAsString2() in psql's describe.c

Поиск
Список
Период
Сортировка
От Daniel Gustafsson
Тема Re: More CppAsString2() in psql's describe.c
Дата
Msg-id B8C14F27-99B0-44BC-8380-2DA8AF671126@yesql.se
обсуждение исходный текст
Ответ на Re: More CppAsString2() in psql's describe.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
> On 2 Dec 2024, at 08:52, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> But isn't there a way to improve the macro so this'd lead to an error?

That sounds like a pretty decent improvement in general.  I experimented with
quick hack using a typeof check on the passed symbol which catches symbolname
typos. It might be totally unfit for purpose but it was an interesting hack.

#define CppAsString2(x) ((__builtin_types_compatible_p(__typeof__(x),char *) ?: CppAsString(x)))

It does require changing the any uses of the macro in string generation from
f("pre" CppAsString2(SYM) "post"); into f_v("pre%spost", CppAsString2(SYM));
however, and using it as part of another macro (TABLESPACE_VERSION_DIRECTORY)
doesn't work.

--
Daniel Gustafsson




В списке pgsql-hackers по дате отправления: