On 2013-12-11 12:37:56 +0100, Florian Pflug wrote:
> On Dec11, 2013, at 11:47 , Andres Freund <and...@2ndquadrant.com> wrote:
> > On 2013-12-11 11:42:25 +0100, Florian Pflug wrote:
> > Yes (although there's C11 stuff to do equivalent stuff afair) - I was
> > thinking of only doing it for compilers we support that dark magic for
> > and fall back to returning a void* for the others. We'll probably miss a
> > cast or two required on !gcc that way, but it's still likely to be less
> > error prone.
> 
> 
> Would it? For this to catch type mismatches, you'd both need to develop
> on a typeof-supporting compiler *and* don't cast the result of 
> relptr_access().
> But you can't really do that, because the code will then fail on compilers
> which don't support typeof()...

Yea, right.

> What we could do, I guess, is to pass the type to relptr_access() and to
> relptr(), and let the compiler verify that they are the same.

Tom and I actually added a macro that's helpful for that recently:
AssertVariableIsOfType(). With that we should be able to get something
reasonable, failing at compile time, with a useful error message even ;)

Greetings,

Andres Freund

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


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to