Re: pgsql: Provide some static-assertion functionality on all compilers.

Поиск
Список
Период
Сортировка
Искать
От
Andres Freund
Тема
Re: pgsql: Provide some static-assertion functionality on all compilers.
Дата
Msg-id
201210181323.04961.andres@2ndquadrant.com
Ответ на
Список
Дерево обсуждения
pgsql: Provide some static-assertion functionality on all compilers. Tom Lane <tgl@sss.pgh.pa.us>
Re: pgsql: Provide some static-assertion functionality on all compilers. Andres Freund <andres@2ndquadrant.com>
Re: pgsql: Provide some static-assertion functionality on all compilers. Tom Lane <tgl@sss.pgh.pa.us>
Re: pgsql: Provide some static-assertion functionality on all compilers. Andres Freund <andres@2ndquadrant.com>
On Tuesday, October 16, 2012 11:50:48 PM Tom Lane wrote:
> Andres Freund  writes:
> > On Monday, October 01, 2012 04:46:41 AM Tom Lane wrote:
> >> Provide some static-assertion functionality on all compilers.
> > 
> > The current method used here doesn't allow the macro to be used in file
> > scope
> 
> > which imo would be rather useful. What about adding something like:
> I deliberately didn't go that way, because I didn't see any methods to
> 
> do it that weren't utter hacks, with deficiencies like this one:
> > Annoyingly that would mean you cannot have two errors in the same line
> > in two files that are in one translation unit if your compiler doesn't
> > allow repeated typedefs. Not sure if thats a realistic problem?
> 
> If it came up even once, it would annoy people no end.  I don't see any
> very strong reason not to just put the assertions inside functions
> instead.

In the case that made me think about it I wanted to assert that internal and 
external data structures are compatible. Putting the static asserts in a 
function relatively far away from the data structures seems to make it more 
likely that adding new asserts will be forgotten.

Unfortunately I don't have a better idea to fix the above deficiency than 
adding another parameter for disambiguation :(

Andres

-- 
 Andres Freund	                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

В списке pgsql-committers по дате отправления
От: Simon Riggs
Дата:
От: Tom Lane
Дата:
FAQ