Skip to content

Commit c8ead2a

Browse files
committed
Provide DLLEXPORT markers for C functions via PG_FUNCTION_INFO_V1 macro.
Second try at the change originally made in commit 8518583; this time with contrib updates so that manual extern declarations are also marked with PGDLLEXPORT. The release notes should point this out as a significant source-code change for extension authors, since they'll have to make similar additions to avoid trouble on Windows. Laurenz Albe, doc change by me Patch: <A737B7A37273E048B164557ADEF4A58B53962ED8@ntex2010a.host.magwien.gv.at>
1 parent 2054071 commit c8ead2a

File tree

4 files changed

+41
-25
lines changed

4 files changed

+41
-25
lines changed

contrib/hstore/hstore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ extern Pairs *hstoreArrayToPairs(ArrayType *a, int *npairs);
194194
#if HSTORE_POLLUTE_NAMESPACE
195195
#define HSTORE_POLLUTE(newname_,oldname_) \
196196
PG_FUNCTION_INFO_V1(oldname_); \
197-
Datum newname_(PG_FUNCTION_ARGS); \
197+
extern PGDLLEXPORT Datum newname_(PG_FUNCTION_ARGS); \
198198
Datum oldname_(PG_FUNCTION_ARGS) { return newname_(fcinfo); } \
199199
extern int no_such_variable
200200
#else

contrib/ltree/ltree.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,30 +130,30 @@ typedef struct
130130

131131

132132
/* use in array iterator */
133-
Datum ltree_isparent(PG_FUNCTION_ARGS);
134-
Datum ltree_risparent(PG_FUNCTION_ARGS);
135-
Datum ltq_regex(PG_FUNCTION_ARGS);
136-
Datum ltq_rregex(PG_FUNCTION_ARGS);
137-
Datum lt_q_regex(PG_FUNCTION_ARGS);
138-
Datum lt_q_rregex(PG_FUNCTION_ARGS);
139-
Datum ltxtq_exec(PG_FUNCTION_ARGS);
140-
Datum ltxtq_rexec(PG_FUNCTION_ARGS);
141-
Datum _ltq_regex(PG_FUNCTION_ARGS);
142-
Datum _ltq_rregex(PG_FUNCTION_ARGS);
143-
Datum _lt_q_regex(PG_FUNCTION_ARGS);
144-
Datum _lt_q_rregex(PG_FUNCTION_ARGS);
145-
Datum _ltxtq_exec(PG_FUNCTION_ARGS);
146-
Datum _ltxtq_rexec(PG_FUNCTION_ARGS);
147-
Datum _ltree_isparent(PG_FUNCTION_ARGS);
148-
Datum _ltree_risparent(PG_FUNCTION_ARGS);
133+
extern PGDLLEXPORT Datum ltree_isparent(PG_FUNCTION_ARGS);
134+
extern PGDLLEXPORT Datum ltree_risparent(PG_FUNCTION_ARGS);
135+
extern PGDLLEXPORT Datum ltq_regex(PG_FUNCTION_ARGS);
136+
extern PGDLLEXPORT Datum ltq_rregex(PG_FUNCTION_ARGS);
137+
extern PGDLLEXPORT Datum lt_q_regex(PG_FUNCTION_ARGS);
138+
extern PGDLLEXPORT Datum lt_q_rregex(PG_FUNCTION_ARGS);
139+
extern PGDLLEXPORT Datum ltxtq_exec(PG_FUNCTION_ARGS);
140+
extern PGDLLEXPORT Datum ltxtq_rexec(PG_FUNCTION_ARGS);
141+
extern PGDLLEXPORT Datum _ltq_regex(PG_FUNCTION_ARGS);
142+
extern PGDLLEXPORT Datum _ltq_rregex(PG_FUNCTION_ARGS);
143+
extern PGDLLEXPORT Datum _lt_q_regex(PG_FUNCTION_ARGS);
144+
extern PGDLLEXPORT Datum _lt_q_rregex(PG_FUNCTION_ARGS);
145+
extern PGDLLEXPORT Datum _ltxtq_exec(PG_FUNCTION_ARGS);
146+
extern PGDLLEXPORT Datum _ltxtq_rexec(PG_FUNCTION_ARGS);
147+
extern PGDLLEXPORT Datum _ltree_isparent(PG_FUNCTION_ARGS);
148+
extern PGDLLEXPORT Datum _ltree_risparent(PG_FUNCTION_ARGS);
149149

150150
/* Concatenation functions */
151-
Datum ltree_addltree(PG_FUNCTION_ARGS);
152-
Datum ltree_addtext(PG_FUNCTION_ARGS);
153-
Datum ltree_textadd(PG_FUNCTION_ARGS);
151+
extern PGDLLEXPORT Datum ltree_addltree(PG_FUNCTION_ARGS);
152+
extern PGDLLEXPORT Datum ltree_addtext(PG_FUNCTION_ARGS);
153+
extern PGDLLEXPORT Datum ltree_textadd(PG_FUNCTION_ARGS);
154154

155155
/* Util function */
156-
Datum ltree_in(PG_FUNCTION_ARGS);
156+
extern PGDLLEXPORT Datum ltree_in(PG_FUNCTION_ARGS);
157157

158158
bool ltree_execute(ITEM *curitem, void *checkval,
159159
bool calcnot, bool (*chkcond) (void *checkval, ITEM *val));

doc/src/sgml/xfunc.sgml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,23 @@ concat_text(PG_FUNCTION_ARGS)
25772577
error messages to this effect.
25782578
</para>
25792579
</listitem>
2580+
2581+
<listitem>
2582+
<para>
2583+
To work correctly on Windows, <literal>C</>-language functions need
2584+
to be marked with <literal>PGDLLEXPORT</>, unless you use a build
2585+
process that marks all global functions that way. In simple cases
2586+
this detail will be handled transparently by
2587+
the <literal>PG_FUNCTION_INFO_V1</> macro. However, if you write
2588+
explicit external declarations (perhaps in header files), be sure
2589+
to write them like this:
2590+
<programlisting>
2591+
extern PGDLLEXPORT Datum funcname(PG_FUNCTION_ARGS);
2592+
</programlisting>
2593+
or you'll get compiler complaints when building on Windows. (On
2594+
other platforms, the <literal>PGDLLEXPORT</> macro does nothing.)
2595+
</para>
2596+
</listitem>
25802597
</itemizedlist>
25812598
</para>
25822599
</sect2>

src/include/fmgr.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,11 @@ typedef const Pg_finfo_record *(*PGFInfoFunction) (void);
350350
*
351351
* On Windows, the function and info function must be exported. Our normal
352352
* build processes take care of that via .DEF files or --export-all-symbols.
353-
* Module authors using a different build process might need to manually
354-
* declare the function PGDLLEXPORT. We do that automatically here for the
355-
* info function, since authors shouldn't need to be explicitly aware of it.
353+
* Module authors using a different build process might do it differently,
354+
* so we declare these functions PGDLLEXPORT for their convenience.
356355
*/
357356
#define PG_FUNCTION_INFO_V1(funcname) \
358-
extern Datum funcname(PG_FUNCTION_ARGS); \
357+
extern PGDLLEXPORT Datum funcname(PG_FUNCTION_ARGS); \
359358
extern PGDLLEXPORT const Pg_finfo_record * CppConcat(pg_finfo_,funcname)(void); \
360359
const Pg_finfo_record * \
361360
CppConcat(pg_finfo_,funcname) (void) \

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy