Re: [HACKERS] static assertions in C++

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: [HACKERS] static assertions in C++
Дата
Msg-id CA+TgmobUcdiP54KfhDybZX-3E9TMn=jA9cFmXZ4SeAEe1ANVaQ@mail.gmail.com
обсуждение исходный текст
Ответ на [HACKERS] static assertions in C++  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Ответы Re: [HACKERS] static assertions in C++  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Thu, Aug 31, 2017 at 4:43 PM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
> Commit df1a699e5ba3232f373790b2c9485ddf720c4a70 introduced a
> StaticAssertStmt() into a header file, which will fail if a module
> written in C++ uses that header file.  Currently, that header file is
> not widely used, but it's a potential problem if the use of static
> assertions expands.
>
> As discussed in
> <https://www.postgresql.org/message-id/7775.1492448671@sss.pgh.pa.us>, a
> more general solution would be to add specific C++ support for static
> assertions in c.h.  Here is a patch for that, extracted from my
> previously posted C++ patch set, but also a bit reworked from what was
> previously posted.

I like the concept of being more C++-compatible, but I'm not sure
about the idea of not providing a workaround, given that we went to
the extreme of doing this:

#define StaticAssertStmt(condition, errmessage) \       ((void) sizeof(struct { int static_assert_failure :
(condition) ? 1 : -1; }))
-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: [HACKERS] static assertions in C++
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] static assertions in C++