I'm writing a small extension, and I'm trying to use C++ constructs. I'm
not actually doing anything that needs C++, but I *really* like declaring
variables when I first initialize them (for example), and I also *really*
like warning-free compiles.

The C++ compiler is mangling the names so they aren't visible to the
extension mechanism. The following page suggests using extern C (it doesn't
specify that this means extern "C", but I suppose anybody who actually knew
what they were doing would have known that immediately):

https://www.postgresql.org/docs/current/xfunc-c.html

So I'm writing my functions to start:

extern "C" Datum ...

The problem is that PG_FUNCTION_INFO_V1 generates its own function
declaration with a conflicting extern specification (just plain extern,
which I guess means "C++" in the context of C++ code).

I also tried wrapping everything - both the functions and
the PG_FUNCTION_INFO_V1 invocations - in extern "C" { ... }, but now a
variable declaration from fmgr.h conflicts with one from the macros.

Is there a simple fix I'm missing? Any hints much appreciated.

Reply via email to