pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Missing declaration of _PG_init()
3+ messages / 3 participants
[nested] [flat]

* Missing declaration of _PG_init()
@ 2021-01-08 14:49  Jack Orenstein <jao@geophile.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Jack Orenstein @ 2021-01-08 14:49 UTC (permalink / raw)
  To: pgsql-general

I am writing an extension. The docs describe a _PG_init function that will
be called upon
loading the shared library (https://www.postgresql.org/docs/12/xfunc-c.html).
I include
postgres.h and fmgr.h, but on compilation, _PG_init has not been declared.
Grepping the postgres source, _PG_init appears to be involved in
programming language extensions, and the function is declared in plpgsql.h.
Looking at various contrib modules, I see
explicit declarations of _PG_init(void).

Should _PG_init(void) be declared in someplace included by postgres.h or
fmgr.h?

Jack Orenstein

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Missing declaration of _PG_init()
@ 2021-01-08 15:38  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: Jack Orenstein <jao@geophile.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Laurenz Albe @ 2021-01-08 15:38 UTC (permalink / raw)
  To: Jack Orenstein <jao@geophile.com>; pgsql-general

On Fri, 2021-01-08 at 09:49 -0500, Jack Orenstein wrote:
> I am writing an extension. The docs describe a _PG_init function that will be called upon
> loading the shared library (https://www.postgresql.org/docs/12/xfunc-c.html). I include
> postgres.h and fmgr.h, but on compilation, _PG_init has not been declared.
>  Grepping the postgres source, _PG_init appears to be involved in programming language
>  extensions, and the function is declared in plpgsql.h. Looking at various contrib modules, I see
> explicit declarations of _PG_init(void). 
> 
> Should _PG_init(void) be declared in someplace included by postgres.h or fmgr.h?

It is provided by your module, so it must be declared by your module:

extern void _PG_init(void);

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Missing declaration of _PG_init()
@ 2021-01-08 15:43  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Jack Orenstein <jao@geophile.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2021-01-08 15:43 UTC (permalink / raw)
  To: Jack Orenstein <jao@geophile.com>; +Cc: pgsql-general

Jack Orenstein <jao@geophile.com> writes:
> Should _PG_init(void) be declared in someplace included by postgres.h or
> fmgr.h?

No, because it's something a given module might or might not provide.
Also, a global extern might give the impression that this was a global
function that the core code provides, rather than a per-module function.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2021-01-08 15:43 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 14:49 Missing declaration of _PG_init() Jack Orenstein <jao@geophile.com>
2021-01-08 15:38 ` Laurenz Albe <laurenz.albe@cybertec.at>
2021-01-08 15:43 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox