postgresql/contrib/hstore
Tom Lane 0d0aa5d291 Provide some static-assertion functionality on all compilers.
On reflection (especially after noticing how many buildfarm critters have
__builtin_types_compatible_p but not _Static_assert), it seems like we
ought to try a bit harder to make these macros do something everywhere.
The initial cut at it would have been no help to code that is compiled only
on platforms without _Static_assert, for instance; and in any case not all
our contributors do their initial coding on the latest gcc version.

Some googling about static assertions turns up quite a bit of prior art
for making it work in compilers that lack _Static_assert.  The method
that seems closest to our needs involves defining a struct with a bit-field
that has negative width if the assertion condition fails.  There seems no
reliable way to get the error message string to be output, but throwing a
compile error with a confusing message is better than missing the problem
altogether.

In the same spirit, if we don't have __builtin_types_compatible_p we can at
least insist that the variable have the same width as the type.  This won't
catch errors such as "wrong pointer type", but it's far better than
nothing.

In addition to changing the macro definitions, adjust a
compile-time-constant Assert in contrib/hstore to use StaticAssertStmt,
so we can get some buildfarm coverage on whether that macro behaves sanely
or not.  There's surely more places that could be converted, but this is
the first one I came across.
2012-09-30 22:46:29 -04:00
..
data
expected
sql
.gitignore
crc32.c
crc32.h
hstore_compat.c Provide some static-assertion functionality on all compilers. 2012-09-30 22:46:29 -04:00
hstore_gin.c
hstore_gist.c Replace int2/int4 in C code with int16/int32 2012-06-25 01:51:46 +03:00
hstore_io.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
hstore_op.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
hstore--1.0--1.1.sql
hstore--1.1.sql
hstore--unpackaged--1.0.sql
hstore.control
hstore.h Replace int2/int4 in C code with int16/int32 2012-06-25 01:51:46 +03:00
Makefile