From b0be28bb7d3d200d7497d782b0d2daf5bc03aa87 Mon Sep 17 00:00:00 2001
From: Laurenz Albe <laurenz.albe@wien.gv.at>
Date: Wed, 12 Oct 2016 16:51:37 +0200
Subject: [PATCH] Add PGDLLEXPORT to PG_FUNCTION_INFO_V1

That way functions declared with the version-1 calling convention
will automatically be exported on Windows.

Note that this is not necessary for building PostgreSQL, as our
build process takes care of exporting the functions, but it will
make things simpler for third party code using a different build
process.
---
 src/include/fmgr.h |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/include/fmgr.h b/src/include/fmgr.h
index 0491e2e..0f04c3e 100644
--- a/src/include/fmgr.h
+++ b/src/include/fmgr.h
@@ -344,11 +344,13 @@ typedef const Pg_finfo_record *(*PGFInfoFunction) (void);
 
 /*
  *	Macro to build an info function associated with the given function name.
- *	Win32 loadable functions usually link with 'dlltool --export-all', but it
- *	doesn't hurt to add PGDLLIMPORT in case they don't.
+ *	The function must be exported, and our build process takes care of that
+ *	so that PGDLLEXPORT would not be necessary for builing PostgreSQL.
+ *	We add it nonetheless so that C functions built with MSVC with a
+ *	different build process are guaranteed to be exported.
  */
 #define PG_FUNCTION_INFO_V1(funcname) \
-Datum funcname(PG_FUNCTION_ARGS); \
+PGDLLEXPORT Datum funcname(PG_FUNCTION_ARGS); \
 extern PGDLLEXPORT const Pg_finfo_record * CppConcat(pg_finfo_,funcname)(void); \
 const Pg_finfo_record * \
 CppConcat(pg_finfo_,funcname) (void) \
-- 
1.7.1

