Isaac Morland <isaac.morl...@gmail.com> writes: > 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.
Well, you could get that with -Wno-declaration-after-statement ... but yeah, this is supposed to work, modulo all the caveats on the page you already found. > The C++ compiler is mangling the names so they aren't visible to the > extension mechanism. Something like the attached works for me; what problem are you having *exactly*? $ g++ -Wall -fno-strict-aliasing -fwrapv -g -O2 -D_GNU_SOURCE -c -I/home/postgres/pgsql/src/include -o test.o test.cpp $ nm --ext --def test.o 0000000000000000 T Pg_magic_func 0000000000000010 T pg_finfo_silly_func 0000000000000020 T silly_func regards, tom lane
extern "C" { #include "postgres.h" #include "fmgr.h" PG_MODULE_MAGIC; PG_FUNCTION_INFO_V1(silly_func); } extern "C" Datum silly_func(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); PG_RETURN_INT32(strlen(str)); }