Can I use extern "C" in an extension so I can use C++?

Поиск
Список
Период
Сортировка
От Isaac Morland
Тема Can I use extern "C" in an extension so I can use C++?
Дата
Msg-id CAMsGm5eOg-SaWKSHkytAnQ_YqfXf2nKxrs=H_Q1XGKcdaGh2DQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: Can I use extern "C" in an extension so I can use C++?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
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):


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.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Daniel Gustafsson
Дата:
Сообщение: Re: vacuum verbose detail logs are unclear; log at *start* of each stage
Следующее
От: Daniel Gustafsson
Дата:
Сообщение: Re: Online checksums verification in the backend