-----Original Message-----
From: Michael Paquier <mich...@paquier.xyz> Sent: Thursday, 19 September 2019 
11:08 AM

>On Wed, Sep 18, 2019 at 04:46:30PM +0100, Dagfinn Ilmari Mannsåker wrote:
>> Postgres doesn't seem to have it, but it would be possible to define a 
>> StaticAssertDecl macro that can be used at the file level, outside any 
>> function.  See for example Perl's STATIC_ASSERT_DECL:
>> 
>> https://github.com/Perl/perl5/blob/v5.30.0/perl.h#L3455-L3488
>
>That sounds like a cleaner alternative.  Thanks for the pointer.

In the attached patch example I have defined a new macro StaticAssertDecl. A 
typical usage of it is shown in the relpath.c file.

The goal was to leave all existing Postgres static assert macros unchanged, but 
to allow static asserts to be added in the code at file scope without the need 
for the explicit ct_asserts function.

Notice, in reality the StaticAssertDecl macro still uses a static function as a 
wrapper for the StaticAssertStmt,  but now the function is not visible in the 
source.

If this strategy is acceptable I will update my original patch to remove all 
those ct_asserts functions, and instead put each StaticAssertDecl nearby the 
array that it is asserting (e.g. just like relpath.c)

Kind Regards,
Peter Smith
---
Fujitsu Australia

Attachment: add_more_ct_asserts_StaticAssertDecl.patch
Description: add_more_ct_asserts_StaticAssertDecl.patch

Reply via email to