Peter Eisentraut <peter.eisentr...@2ndquadrant.com> writes: > On 12/11/17 17:12, Tom Lane wrote: >> Hmm, well, surely there's more than one way to do that; the sizeof >> is just a convenient way to wrap it in C. Wouldn't a typedef serve >> just as well?
> Here is another attempt, which has the desired effect with the handful > of compilers I have available. I can confirm that the negative-bitfield-width method employed here has the desired effects (i.e., error or not, without unwanted warnings) on the oldest C++ compilers I have handy, namely $ g++ -v Reading specs from /usr/local/lib/gcc-lib/hppa2.0-hp-hpux10.20/2.95.3/specs gcc version 2.95.3 20010315 (release) $ g++ -v Using built-in specs. Target: powerpc-apple-darwin8 Configured with: /private/var/tmp/gcc/gcc-5341.obj~1/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 --target=powerpc-apple-darwin8 Thread model: posix gcc version 4.0.1 (Apple Computer, Inc. build 5341) I do not have a well-informed opinion on whether #if defined(__cpp_static_assert) && __cpp_static_assert >= 200410 is an appropriate test for static_assert() being available, but I'm pretty suspicious of it because none of my C++ compilers seem to take that path, not even recent stuff like clang 9.0.0. However, since the negative-bitfield-width code path works anyway, that's something we could refine later. In short, I think this could be committed as-is, but later we might want to do some more research on how to tell whether static_assert() is available. regards, tom lane