Hi,

I've been pinged many time over the years to either fix Windows compatibility
or provide DLL for multiple extensions I'm maintaining.  I've finally taken
some time to setup a Windows build environment so I could take care of most of
the problem, but not all (at least not in a satisfactory way).

I've also been looking a bit around other extensions and I see that the #1
problem with compiling extensions on Windows is the lack of PGDLLIMPORT
annotations, which is 99% of the time for a GUC.

This topic has been raised multiple time over the years, and I don't see any
objection to add such an annotation at least for all GUC variables (either the
direct variables or the indirect variables set during the hook execution), so
PFA a patch that takes care of all the GUC.

I don't now if that's still an option at that point, but backporting to at
least pg14 if that patch is accepted would be quite helpful.
>From 10af6e965ace671aad13cae47ee1b475ac24f15a Mon Sep 17 00:00:00 2001
From: Julien Rouhaud <julien.rouh...@free.fr>
Date: Sun, 22 Aug 2021 15:40:47 +0800
Subject: [PATCH v1] Add PGDLLIMPORT to all direct or indirect GUC variables

---
 src/backend/utils/misc/guc.c              | 18 +++---
 src/include/access/gin.h                  |  2 +-
 src/include/access/tableam.h              |  4 +-
 src/include/access/toast_compression.h    |  2 +-
 src/include/access/xact.h                 | 12 ++--
 src/include/access/xlog.h                 | 78 +++++++++++------------
 src/include/catalog/namespace.h           |  2 +-
 src/include/catalog/storage.h             |  2 +-
 src/include/commands/async.h              |  2 +-
 src/include/commands/user.h               |  2 +-
 src/include/commands/vacuum.h             | 12 ++--
 src/include/fmgr.h                        |  2 +-
 src/include/jit/jit.h                     | 20 +++---
 src/include/libpq/auth.h                  |  4 +-
 src/include/libpq/libpq.h                 | 24 +++----
 src/include/libpq/pqcomm.h                |  2 +-
 src/include/miscadmin.h                   | 22 +++----
 src/include/optimizer/geqo.h              | 10 +--
 src/include/optimizer/optimizer.h         |  4 +-
 src/include/optimizer/planmain.h          |  6 +-
 src/include/parser/parse_expr.h           |  2 +-
 src/include/parser/parser.h               |  4 +-
 src/include/pgstat.h                      |  6 +-
 src/include/pgtime.h                      |  2 +-
 src/include/postmaster/autovacuum.h       | 30 ++++-----
 src/include/postmaster/bgwriter.h         |  8 +--
 src/include/postmaster/postmaster.h       | 28 ++++----
 src/include/postmaster/syslogger.h        | 10 +--
 src/include/postmaster/walwriter.h        |  4 +-
 src/include/replication/logicallauncher.h |  4 +-
 src/include/replication/syncrep.h         |  2 +-
 src/include/replication/walreceiver.h     |  6 +-
 src/include/replication/walsender.h       |  6 +-
 src/include/storage/bufmgr.h              | 20 +++---
 src/include/storage/dsm_impl.h            |  4 +-
 src/include/storage/fd.h                  |  2 +-
 src/include/storage/large_object.h        |  2 +-
 src/include/storage/lock.h                | 12 ++--
 src/include/storage/lwlock.h              |  2 +-
 src/include/storage/pg_shmem.h            |  6 +-
 src/include/storage/predicate.h           |  6 +-
 src/include/storage/proc.h                |  2 +-
 src/include/storage/standby.h             |  8 +--
 src/include/tcop/tcopprot.h               |  6 +-
 src/include/tsearch/ts_cache.h            |  2 +-
 src/include/utils/array.h                 |  2 +-
 src/include/utils/builtins.h              |  2 +-
 src/include/utils/bytea.h                 |  2 +-
 src/include/utils/elog.h                  | 10 +--
 src/include/utils/guc.h                   | 62 +++++++++---------
 src/include/utils/pg_locale.h             |  8 +--
 src/include/utils/plancache.h             |  2 +-
 src/include/utils/ps_status.h             |  2 +-
 src/include/utils/queryjumble.h           |  2 +-
 src/include/utils/rls.h                   |  2 +-
 src/include/utils/xml.h                   |  4 +-
 56 files changed, 256 insertions(+), 256 deletions(-)

diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index a2e0f8de7e..145aeed94b 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -129,20 +129,20 @@
 #define REALTYPE_PRECISION 17
 
 /* XXX these should appear in other modules' header files */
-extern bool Log_disconnections;
-extern int	CommitDelay;
-extern int	CommitSiblings;
-extern char *default_tablespace;
-extern char *temp_tablespaces;
-extern bool ignore_checksum_failure;
-extern bool ignore_invalid_pages;
+extern PGDLLIMPORT bool Log_disconnections;
+extern PGDLLIMPORT int	CommitDelay;
+extern PGDLLIMPORT int	CommitSiblings;
+extern PGDLLIMPORT char *default_tablespace;
+extern PGDLLIMPORT char *temp_tablespaces;
+extern PGDLLIMPORT bool ignore_checksum_failure;
+extern PGDLLIMPORT bool ignore_invalid_pages;
 extern bool synchronize_seqscans;
 
 #ifdef TRACE_SYNCSCAN
-extern bool trace_syncscan;
+extern PGDLLIMPORT bool trace_syncscan;
 #endif
 #ifdef DEBUG_BOUNDED_SORT
-extern bool optimize_bounded_sort;
+extern PGDLLIMPORT bool optimize_bounded_sort;
 #endif
 
 static int	GUC_check_errcode_value;
diff --git a/src/include/access/gin.h b/src/include/access/gin.h
index 266cb07236..893cf57bc1 100644
--- a/src/include/access/gin.h
+++ b/src/include/access/gin.h
@@ -68,7 +68,7 @@ typedef char GinTernaryValue;
 
 /* GUC parameters */
 extern PGDLLIMPORT int GinFuzzySearchLimit;
-extern int	gin_pending_list_limit;
+extern PGDLLIMPORT int	gin_pending_list_limit;
 
 /* ginutil.c */
 extern void ginGetStats(Relation index, GinStatsData *stats);
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h
index 9f1e4a1ac9..1d8646b080 100644
--- a/src/include/access/tableam.h
+++ b/src/include/access/tableam.h
@@ -28,8 +28,8 @@
 #define DEFAULT_TABLE_ACCESS_METHOD	"heap"
 
 /* GUCs */
-extern char *default_table_access_method;
-extern bool synchronize_seqscans;
+extern PGDLLIMPORT char *default_table_access_method;
+extern PGDLLIMPORT bool synchronize_seqscans;
 
 
 struct BulkInsertStateData;
diff --git a/src/include/access/toast_compression.h b/src/include/access/toast_compression.h
index c992ece4c4..efc218087b 100644
--- a/src/include/access/toast_compression.h
+++ b/src/include/access/toast_compression.h
@@ -20,7 +20,7 @@
  * but the value is one of the char values defined below, as they appear in
  * pg_attribute.attcompression, e.g. TOAST_PGLZ_COMPRESSION.
  */
-extern int	default_toast_compression;
+extern PGDLLIMPORT int	default_toast_compression;
 
 /*
  * Built-in compression method ID.  The toast compression header will store
diff --git a/src/include/access/xact.h b/src/include/access/xact.h
index 134f6862da..00511dcb63 100644
--- a/src/include/access/xact.h
+++ b/src/include/access/xact.h
@@ -38,7 +38,7 @@
 #define XACT_REPEATABLE_READ	2
 #define XACT_SERIALIZABLE		3
 
-extern int	DefaultXactIsoLevel;
+extern PGDLLIMPORT int	DefaultXactIsoLevel;
 extern PGDLLIMPORT int XactIsoLevel;
 
 /*
@@ -52,8 +52,8 @@ extern PGDLLIMPORT int XactIsoLevel;
 #define IsolationIsSerializable() (XactIsoLevel == XACT_SERIALIZABLE)
 
 /* Xact read-only state */
-extern bool DefaultXactReadOnly;
-extern bool XactReadOnly;
+extern PGDLLIMPORT bool DefaultXactReadOnly;
+extern PGDLLIMPORT bool XactReadOnly;
 
 /* flag for logging statements in this transaction */
 extern bool xact_is_sampled;
@@ -62,8 +62,8 @@ extern bool xact_is_sampled;
  * Xact is deferrable -- only meaningful (currently) for read only
  * SERIALIZABLE transactions
  */
-extern bool DefaultXactDeferrable;
-extern bool XactDeferrable;
+extern PGDLLIMPORT bool DefaultXactDeferrable;
+extern PGDLLIMPORT bool XactDeferrable;
 
 typedef enum
 {
@@ -80,7 +80,7 @@ typedef enum
 #define SYNCHRONOUS_COMMIT_ON	SYNCHRONOUS_COMMIT_REMOTE_FLUSH
 
 /* Synchronous commit level */
-extern int	synchronous_commit;
+extern PGDLLIMPORT int	synchronous_commit;
 
 /* used during logical streaming of a transaction */
 extern PGDLLIMPORT TransactionId CheckXidAlive;
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index 0a8ede700d..d2ee540b08 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -27,7 +27,7 @@
 #define SYNC_METHOD_OPEN		2	/* for O_SYNC */
 #define SYNC_METHOD_FSYNC_WRITETHROUGH	3
 #define SYNC_METHOD_OPEN_DSYNC	4	/* for O_DSYNC */
-extern int	sync_method;
+extern PGDLLIMPORT int	sync_method;
 
 extern PGDLLIMPORT TimeLineID ThisTimeLineID;	/* current TLI */
 
@@ -62,45 +62,45 @@ extern PGDLLIMPORT XLogRecPtr XactLastCommitEnd;
 extern bool reachedConsistency;
 
 /* these variables are GUC parameters related to XLOG */
-extern int	wal_segment_size;
-extern int	min_wal_size_mb;
-extern int	max_wal_size_mb;
-extern int	wal_keep_size_mb;
-extern int	max_slot_wal_keep_size_mb;
-extern int	XLOGbuffers;
-extern int	XLogArchiveTimeout;
-extern int	wal_retrieve_retry_interval;
-extern char *XLogArchiveCommand;
-extern bool EnableHotStandby;
-extern bool fullPageWrites;
-extern bool wal_log_hints;
-extern int	wal_compression;
-extern bool wal_init_zero;
-extern bool wal_recycle;
+extern PGDLLIMPORT int	wal_segment_size;
+extern PGDLLIMPORT int	min_wal_size_mb;
+extern PGDLLIMPORT int	max_wal_size_mb;
+extern PGDLLIMPORT int	wal_keep_size_mb;
+extern PGDLLIMPORT int	max_slot_wal_keep_size_mb;
+extern PGDLLIMPORT int	XLOGbuffers;
+extern PGDLLIMPORT int	XLogArchiveTimeout;
+extern PGDLLIMPORT int	wal_retrieve_retry_interval;
+extern PGDLLIMPORT char *XLogArchiveCommand;
+extern PGDLLIMPORT bool EnableHotStandby;
+extern PGDLLIMPORT bool fullPageWrites;
+extern PGDLLIMPORT bool wal_log_hints;
+extern PGDLLIMPORT int	wal_compression;
+extern PGDLLIMPORT bool wal_init_zero;
+extern PGDLLIMPORT bool wal_recycle;
 extern bool *wal_consistency_checking;
-extern char *wal_consistency_checking_string;
-extern bool log_checkpoints;
-extern char *recoveryRestoreCommand;
-extern char *recoveryEndCommand;
-extern char *archiveCleanupCommand;
-extern bool recoveryTargetInclusive;
-extern int	recoveryTargetAction;
-extern int	recovery_min_apply_delay;
-extern char *PrimaryConnInfo;
-extern char *PrimarySlotName;
-extern bool wal_receiver_create_temp_slot;
-extern bool track_wal_io_timing;
+extern PGDLLIMPORT char *wal_consistency_checking_string;
+extern PGDLLIMPORT bool log_checkpoints;
+extern PGDLLIMPORT char *recoveryRestoreCommand;
+extern PGDLLIMPORT char *recoveryEndCommand;
+extern PGDLLIMPORT char *archiveCleanupCommand;
+extern PGDLLIMPORT bool recoveryTargetInclusive;
+extern PGDLLIMPORT int	recoveryTargetAction;
+extern PGDLLIMPORT int	recovery_min_apply_delay;
+extern PGDLLIMPORT char *PrimaryConnInfo;
+extern PGDLLIMPORT char *PrimarySlotName;
+extern PGDLLIMPORT bool wal_receiver_create_temp_slot;
+extern PGDLLIMPORT bool track_wal_io_timing;
 
 /* indirectly set via GUC system */
-extern TransactionId recoveryTargetXid;
-extern char *recovery_target_time_string;
-extern const char *recoveryTargetName;
-extern XLogRecPtr recoveryTargetLSN;
-extern RecoveryTargetType recoveryTarget;
-extern char *PromoteTriggerFile;
-extern RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal;
-extern TimeLineID recoveryTargetTLIRequested;
-extern TimeLineID recoveryTargetTLI;
+extern PGDLLIMPORT TransactionId recoveryTargetXid;
+extern PGDLLIMPORT char *recovery_target_time_string;
+extern PGDLLIMPORT const char *recoveryTargetName;
+extern PGDLLIMPORT XLogRecPtr recoveryTargetLSN;
+extern PGDLLIMPORT RecoveryTargetType recoveryTarget;
+extern PGDLLIMPORT char *PromoteTriggerFile;
+extern PGDLLIMPORT RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal;
+extern PGDLLIMPORT TimeLineID recoveryTargetTLIRequested;
+extern PGDLLIMPORT TimeLineID recoveryTargetTLI;
 
 extern int	CheckPointSegments;
 
@@ -115,7 +115,7 @@ typedef enum ArchiveMode
 	ARCHIVE_MODE_ON,			/* enabled while server is running normally */
 	ARCHIVE_MODE_ALWAYS			/* enabled always (even during recovery) */
 } ArchiveMode;
-extern int	XLogArchiveMode;
+extern PGDLLIMPORT int	XLogArchiveMode;
 
 /* WAL levels */
 typedef enum WalLevel
@@ -183,7 +183,7 @@ extern PGDLLIMPORT int wal_level;
 #define XLogLogicalInfoActive() (wal_level >= WAL_LEVEL_LOGICAL)
 
 #ifdef WAL_DEBUG
-extern bool XLOG_DEBUG;
+extern PGDLLIMPORT bool XLOG_DEBUG;
 #endif
 
 /*
diff --git a/src/include/catalog/namespace.h b/src/include/catalog/namespace.h
index b98f284356..f72956dfa9 100644
--- a/src/include/catalog/namespace.h
+++ b/src/include/catalog/namespace.h
@@ -182,7 +182,7 @@ extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
 								  SubTransactionId parentSubid);
 
 /* stuff for search_path GUC variable */
-extern char *namespace_search_path;
+extern PGDLLIMPORT char *namespace_search_path;
 
 extern List *fetch_search_path(bool includeImplicit);
 extern int	fetch_search_path_array(Oid *sarray, int sarray_len);
diff --git a/src/include/catalog/storage.h b/src/include/catalog/storage.h
index 0ab32b44e9..b6dbdbc8a5 100644
--- a/src/include/catalog/storage.h
+++ b/src/include/catalog/storage.h
@@ -20,7 +20,7 @@
 #include "utils/relcache.h"
 
 /* GUC variables */
-extern int	wal_skip_threshold;
+extern PGDLLIMPORT int	wal_skip_threshold;
 
 extern SMgrRelation RelationCreateStorage(RelFileNode rnode, char relpersistence);
 extern void RelationDropStorage(Relation rel);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 9217f66b91..88f2d206d2 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -20,7 +20,7 @@
  */
 #define NUM_NOTIFY_BUFFERS	8
 
-extern bool Trace_notify;
+extern PGDLLIMPORT bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
 extern Size AsyncShmemSize(void);
diff --git a/src/include/commands/user.h b/src/include/commands/user.h
index 0b7a3cd65f..d5159f3fe5 100644
--- a/src/include/commands/user.h
+++ b/src/include/commands/user.h
@@ -17,7 +17,7 @@
 #include "parser/parse_node.h"
 
 /* GUC. Is actually of type PasswordType. */
-extern int	Password_encryption;
+extern PGDLLIMPORT int	Password_encryption;
 
 /* Hook to check passwords in CreateRole() and AlterRole() */
 typedef void (*check_password_hook_type) (const char *username, const char *shadow_pass, PasswordType password_type, Datum validuntil_time, bool validuntil_null);
diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h
index bf3126aa9b..4f682afbb1 100644
--- a/src/include/commands/vacuum.h
+++ b/src/include/commands/vacuum.h
@@ -232,12 +232,12 @@ typedef struct VacuumParams
 
 /* GUC parameters */
 extern PGDLLIMPORT int default_statistics_target;	/* PGDLLIMPORT for PostGIS */
-extern int	vacuum_freeze_min_age;
-extern int	vacuum_freeze_table_age;
-extern int	vacuum_multixact_freeze_min_age;
-extern int	vacuum_multixact_freeze_table_age;
-extern int	vacuum_failsafe_age;
-extern int	vacuum_multixact_failsafe_age;
+extern PGDLLIMPORT int	vacuum_freeze_min_age;
+extern PGDLLIMPORT int	vacuum_freeze_table_age;
+extern PGDLLIMPORT int	vacuum_multixact_freeze_min_age;
+extern PGDLLIMPORT int	vacuum_multixact_freeze_table_age;
+extern PGDLLIMPORT int	vacuum_failsafe_age;
+extern PGDLLIMPORT int	vacuum_multixact_failsafe_age;
 
 /* Variables for cost-based parallel vacuum */
 extern pg_atomic_uint32 *VacuumSharedCostBalance;
diff --git a/src/include/fmgr.h b/src/include/fmgr.h
index ab7b85c86e..d394c4afa2 100644
--- a/src/include/fmgr.h
+++ b/src/include/fmgr.h
@@ -716,7 +716,7 @@ extern bool CheckFunctionValidatorAccess(Oid validatorOid, Oid functionOid);
 /*
  * Routines in dfmgr.c
  */
-extern char *Dynamic_library_path;
+extern PGDLLIMPORT char *Dynamic_library_path;
 
 extern void *load_external_function(const char *filename, const char *funcname,
 									bool signalNotFound, void **filehandle);
diff --git a/src/include/jit/jit.h b/src/include/jit/jit.h
index b634df30b9..7730a77aef 100644
--- a/src/include/jit/jit.h
+++ b/src/include/jit/jit.h
@@ -79,16 +79,16 @@ struct JitProviderCallbacks
 
 
 /* GUCs */
-extern bool jit_enabled;
-extern char *jit_provider;
-extern bool jit_debugging_support;
-extern bool jit_dump_bitcode;
-extern bool jit_expressions;
-extern bool jit_profiling_support;
-extern bool jit_tuple_deforming;
-extern double jit_above_cost;
-extern double jit_inline_above_cost;
-extern double jit_optimize_above_cost;
+extern PGDLLIMPORT bool jit_enabled;
+extern PGDLLIMPORT char *jit_provider;
+extern PGDLLIMPORT bool jit_debugging_support;
+extern PGDLLIMPORT bool jit_dump_bitcode;
+extern PGDLLIMPORT bool jit_expressions;
+extern PGDLLIMPORT bool jit_profiling_support;
+extern PGDLLIMPORT bool jit_tuple_deforming;
+extern PGDLLIMPORT double jit_above_cost;
+extern PGDLLIMPORT double jit_inline_above_cost;
+extern PGDLLIMPORT double jit_optimize_above_cost;
 
 
 extern void jit_reset_after_error(void);
diff --git a/src/include/libpq/auth.h b/src/include/libpq/auth.h
index 3d6734f253..34bec0c91a 100644
--- a/src/include/libpq/auth.h
+++ b/src/include/libpq/auth.h
@@ -16,8 +16,8 @@
 
 #include "libpq/libpq-be.h"
 
-extern char *pg_krb_server_keyfile;
-extern bool pg_krb_caseins_users;
+extern PGDLLIMPORT char *pg_krb_server_keyfile;
+extern PGDLLIMPORT bool pg_krb_caseins_users;
 extern char *pg_krb_realm;
 
 extern void ClientAuthentication(Port *port);
diff --git a/src/include/libpq/libpq.h b/src/include/libpq/libpq.h
index 6c51b2f20f..b4dbd909f5 100644
--- a/src/include/libpq/libpq.h
+++ b/src/include/libpq/libpq.h
@@ -85,13 +85,13 @@ extern bool pq_check_connection(void);
 /*
  * prototypes for functions in be-secure.c
  */
-extern char *ssl_library;
-extern char *ssl_cert_file;
-extern char *ssl_key_file;
-extern char *ssl_ca_file;
-extern char *ssl_crl_file;
-extern char *ssl_crl_dir;
-extern char *ssl_dh_params_file;
+extern PGDLLIMPORT char *ssl_library;
+extern PGDLLIMPORT char *ssl_cert_file;
+extern PGDLLIMPORT char *ssl_key_file;
+extern PGDLLIMPORT char *ssl_ca_file;
+extern PGDLLIMPORT char *ssl_crl_file;
+extern PGDLLIMPORT char *ssl_crl_dir;
+extern PGDLLIMPORT char *ssl_dh_params_file;
 extern PGDLLIMPORT char *ssl_passphrase_command;
 extern PGDLLIMPORT bool ssl_passphrase_command_supports_reload;
 #ifdef USE_SSL
@@ -116,11 +116,11 @@ extern ssize_t secure_open_gssapi(Port *port);
 #endif
 
 /* GUCs */
-extern char *SSLCipherSuites;
-extern char *SSLECDHCurve;
-extern bool SSLPreferServerCiphers;
-extern int	ssl_min_protocol_version;
-extern int	ssl_max_protocol_version;
+extern PGDLLIMPORT char *SSLCipherSuites;
+extern PGDLLIMPORT char *SSLECDHCurve;
+extern PGDLLIMPORT bool SSLPreferServerCiphers;
+extern PGDLLIMPORT int	ssl_min_protocol_version;
+extern PGDLLIMPORT int	ssl_max_protocol_version;
 
 enum ssl_protocol_versions
 {
diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h
index be9d970574..64687c37b0 100644
--- a/src/include/libpq/pqcomm.h
+++ b/src/include/libpq/pqcomm.h
@@ -135,7 +135,7 @@ typedef ProtocolVersion MsgType;
 
 typedef uint32 PacketLen;
 
-extern bool Db_user_namespace;
+extern PGDLLIMPORT bool Db_user_namespace;
 
 /*
  * In protocol 3.0 and later, the startup packet length is not fixed, but
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 2e2e9a364a..7d6f164037 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -255,18 +255,18 @@ extern PGDLLIMPORT int IntervalStyle;
 
 #define MAXTZLEN		10		/* max TZ name len, not counting tr. null */
 
-extern bool enableFsync;
+extern PGDLLIMPORT bool enableFsync;
 extern PGDLLIMPORT bool allowSystemTableMods;
 extern PGDLLIMPORT int work_mem;
 extern PGDLLIMPORT double hash_mem_multiplier;
 extern PGDLLIMPORT int maintenance_work_mem;
 extern PGDLLIMPORT int max_parallel_maintenance_workers;
 
-extern int	VacuumCostPageHit;
-extern int	VacuumCostPageMiss;
-extern int	VacuumCostPageDirty;
-extern int	VacuumCostLimit;
-extern double VacuumCostDelay;
+extern PGDLLIMPORT int	VacuumCostPageHit;
+extern PGDLLIMPORT int	VacuumCostPageMiss;
+extern PGDLLIMPORT int	VacuumCostPageDirty;
+extern PGDLLIMPORT int	VacuumCostLimit;
+extern PGDLLIMPORT double VacuumCostDelay;
 
 extern int64 VacuumPageHit;
 extern int64 VacuumPageMiss;
@@ -299,7 +299,7 @@ extern void PreventCommandIfParallelMode(const char *cmdname);
 extern void PreventCommandDuringRecovery(const char *cmdname);
 
 /* in utils/misc/guc.c */
-extern int	trace_recovery_messages;
+extern PGDLLIMPORT int	trace_recovery_messages;
 extern int	trace_recovery(int trace_level);
 
 /*****************************************************************************
@@ -460,11 +460,11 @@ extern void InitPostgres(const char *in_dbname, Oid dboid, const char *username,
 extern void BaseInit(void);
 
 /* in utils/init/miscinit.c */
-extern bool IgnoreSystemIndexes;
+extern PGDLLIMPORT bool IgnoreSystemIndexes;
 extern PGDLLIMPORT bool process_shared_preload_libraries_in_progress;
-extern char *session_preload_libraries_string;
-extern char *shared_preload_libraries_string;
-extern char *local_preload_libraries_string;
+extern PGDLLIMPORT char *session_preload_libraries_string;
+extern PGDLLIMPORT char *shared_preload_libraries_string;
+extern PGDLLIMPORT char *local_preload_libraries_string;
 
 extern void CreateDataDirLockFile(bool amPostmaster);
 extern void CreateSocketLockFile(const char *socketfile, bool amPostmaster,
diff --git a/src/include/optimizer/geqo.h b/src/include/optimizer/geqo.h
index 24dcdfb6cc..dd548232cf 100644
--- a/src/include/optimizer/geqo.h
+++ b/src/include/optimizer/geqo.h
@@ -48,23 +48,23 @@
  *
  * If you change these, update backend/utils/misc/postgresql.conf.sample
  */
-extern int	Geqo_effort;		/* 1 .. 10, knob for adjustment of defaults */
+extern PGDLLIMPORT int	Geqo_effort;		/* 1 .. 10, knob for adjustment of defaults */
 
 #define DEFAULT_GEQO_EFFORT 5
 #define MIN_GEQO_EFFORT 1
 #define MAX_GEQO_EFFORT 10
 
-extern int	Geqo_pool_size;		/* 2 .. inf, or 0 to use default */
+extern PGDLLIMPORT int	Geqo_pool_size;		/* 2 .. inf, or 0 to use default */
 
-extern int	Geqo_generations;	/* 1 .. inf, or 0 to use default */
+extern PGDLLIMPORT int	Geqo_generations;	/* 1 .. inf, or 0 to use default */
 
-extern double Geqo_selection_bias;
+extern PGDLLIMPORT double Geqo_selection_bias;
 
 #define DEFAULT_GEQO_SELECTION_BIAS 2.0
 #define MIN_GEQO_SELECTION_BIAS 1.5
 #define MAX_GEQO_SELECTION_BIAS 2.0
 
-extern double Geqo_seed;		/* 0 .. 1 */
+extern PGDLLIMPORT double Geqo_seed;		/* 0 .. 1 */
 
 
 /*
diff --git a/src/include/optimizer/optimizer.h b/src/include/optimizer/optimizer.h
index 41b49b2662..db259f7d7a 100644
--- a/src/include/optimizer/optimizer.h
+++ b/src/include/optimizer/optimizer.h
@@ -111,8 +111,8 @@ typedef enum
 }			ForceParallelMode;
 
 /* GUC parameters */
-extern int	force_parallel_mode;
-extern bool parallel_leader_participation;
+extern PGDLLIMPORT int	force_parallel_mode;
+extern PGDLLIMPORT bool parallel_leader_participation;
 
 extern struct PlannedStmt *planner(Query *parse, const char *query_string,
 								   int cursorOptions,
diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
index bf1adfc52a..4c622bbda9 100644
--- a/src/include/optimizer/planmain.h
+++ b/src/include/optimizer/planmain.h
@@ -19,7 +19,7 @@
 
 /* GUC parameters */
 #define DEFAULT_CURSOR_TUPLE_FRACTION 0.1
-extern double cursor_tuple_fraction;
+extern PGDLLIMPORT double cursor_tuple_fraction;
 
 /* query_planner callback to compute query_pathkeys */
 typedef void (*query_pathkeys_callback) (PlannerInfo *root, void *extra);
@@ -64,8 +64,8 @@ extern Limit *make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount,
 /*
  * prototypes for plan/initsplan.c
  */
-extern int	from_collapse_limit;
-extern int	join_collapse_limit;
+extern PGDLLIMPORT int	from_collapse_limit;
+extern PGDLLIMPORT int	join_collapse_limit;
 
 extern void add_base_rels_to_query(PlannerInfo *root, Node *jtnode);
 extern void add_other_rels_to_query(PlannerInfo *root);
diff --git a/src/include/parser/parse_expr.h b/src/include/parser/parse_expr.h
index 8ac4a0a369..903aaaf1ec 100644
--- a/src/include/parser/parse_expr.h
+++ b/src/include/parser/parse_expr.h
@@ -16,7 +16,7 @@
 #include "parser/parse_node.h"
 
 /* GUC parameters */
-extern bool Transform_null_equals;
+extern PGDLLIMPORT bool Transform_null_equals;
 
 extern Node *transformExpr(ParseState *pstate, Node *expr, ParseExprKind exprKind);
 
diff --git a/src/include/parser/parser.h b/src/include/parser/parser.h
index 853b0f1606..2c7c315266 100644
--- a/src/include/parser/parser.h
+++ b/src/include/parser/parser.h
@@ -53,8 +53,8 @@ typedef enum
 }			BackslashQuoteType;
 
 /* GUC variables in scan.l (every one of these is a bad idea :-() */
-extern int	backslash_quote;
-extern bool escape_string_warning;
+extern PGDLLIMPORT int	backslash_quote;
+extern PGDLLIMPORT bool escape_string_warning;
 extern PGDLLIMPORT bool standard_conforming_strings;
 
 
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 509849c7ff..36e0cfa56f 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -940,9 +940,9 @@ typedef struct PgStat_FunctionCallUsage
  */
 extern PGDLLIMPORT bool pgstat_track_counts;
 extern PGDLLIMPORT int pgstat_track_functions;
-extern char *pgstat_stat_directory;
-extern char *pgstat_stat_tmpname;
-extern char *pgstat_stat_filename;
+extern PGDLLIMPORT char *pgstat_stat_directory;
+extern PGDLLIMPORT char *pgstat_stat_tmpname;
+extern PGDLLIMPORT char *pgstat_stat_filename;
 
 /*
  * BgWriter statistics counters are updated directly by bgwriter and bufmgr
diff --git a/src/include/pgtime.h b/src/include/pgtime.h
index 28bd27e7f7..8ec68fd5f2 100644
--- a/src/include/pgtime.h
+++ b/src/include/pgtime.h
@@ -71,7 +71,7 @@ extern size_t pg_strftime(char *s, size_t max, const char *format,
 /* these functions and variables are in pgtz.c */
 
 extern PGDLLIMPORT pg_tz *session_timezone;
-extern pg_tz *log_timezone;
+extern PGDLLIMPORT pg_tz *log_timezone;
 
 extern void pg_timezone_initialize(void);
 extern pg_tz *pg_tzset(const char *tzname);
diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h
index aacdd0f575..9f067dfeac 100644
--- a/src/include/postmaster/autovacuum.h
+++ b/src/include/postmaster/autovacuum.h
@@ -27,25 +27,25 @@ typedef enum
 
 
 /* GUC variables */
-extern bool autovacuum_start_daemon;
-extern int	autovacuum_max_workers;
-extern int	autovacuum_work_mem;
-extern int	autovacuum_naptime;
-extern int	autovacuum_vac_thresh;
-extern double autovacuum_vac_scale;
-extern int	autovacuum_vac_ins_thresh;
-extern double autovacuum_vac_ins_scale;
-extern int	autovacuum_anl_thresh;
-extern double autovacuum_anl_scale;
-extern int	autovacuum_freeze_max_age;
-extern int	autovacuum_multixact_freeze_max_age;
-extern double autovacuum_vac_cost_delay;
-extern int	autovacuum_vac_cost_limit;
+extern PGDLLIMPORT bool autovacuum_start_daemon;
+extern PGDLLIMPORT int	autovacuum_max_workers;
+extern PGDLLIMPORT int	autovacuum_work_mem;
+extern PGDLLIMPORT int	autovacuum_naptime;
+extern PGDLLIMPORT int	autovacuum_vac_thresh;
+extern PGDLLIMPORT double autovacuum_vac_scale;
+extern PGDLLIMPORT int	autovacuum_vac_ins_thresh;
+extern PGDLLIMPORT double autovacuum_vac_ins_scale;
+extern PGDLLIMPORT int	autovacuum_anl_thresh;
+extern PGDLLIMPORT double autovacuum_anl_scale;
+extern PGDLLIMPORT int	autovacuum_freeze_max_age;
+extern PGDLLIMPORT int	autovacuum_multixact_freeze_max_age;
+extern PGDLLIMPORT double autovacuum_vac_cost_delay;
+extern PGDLLIMPORT int	autovacuum_vac_cost_limit;
 
 /* autovacuum launcher PID, only valid when worker is shutting down */
 extern int	AutovacuumLauncherPid;
 
-extern int	Log_autovacuum_min_duration;
+extern PGDLLIMPORT int	Log_autovacuum_min_duration;
 
 /* Status inquiry functions */
 extern bool AutoVacuumingActive(void);
diff --git a/src/include/postmaster/bgwriter.h b/src/include/postmaster/bgwriter.h
index c430b1b236..7089a2682c 100644
--- a/src/include/postmaster/bgwriter.h
+++ b/src/include/postmaster/bgwriter.h
@@ -22,10 +22,10 @@
 
 
 /* GUC options */
-extern int	BgWriterDelay;
-extern int	CheckPointTimeout;
-extern int	CheckPointWarning;
-extern double CheckPointCompletionTarget;
+extern PGDLLIMPORT int	BgWriterDelay;
+extern PGDLLIMPORT int	CheckPointTimeout;
+extern PGDLLIMPORT int	CheckPointWarning;
+extern PGDLLIMPORT double CheckPointCompletionTarget;
 
 extern void BackgroundWriterMain(void) pg_attribute_noreturn();
 extern void CheckpointerMain(void) pg_attribute_noreturn();
diff --git a/src/include/postmaster/postmaster.h b/src/include/postmaster/postmaster.h
index 0efdd7c232..bea67c3719 100644
--- a/src/include/postmaster/postmaster.h
+++ b/src/include/postmaster/postmaster.h
@@ -14,22 +14,22 @@
 #define _POSTMASTER_H
 
 /* GUC options */
-extern bool EnableSSL;
-extern int	ReservedBackends;
+extern PGDLLIMPORT bool EnableSSL;
+extern PGDLLIMPORT int	ReservedBackends;
 extern PGDLLIMPORT int PostPortNumber;
-extern int	Unix_socket_permissions;
-extern char *Unix_socket_group;
-extern char *Unix_socket_directories;
-extern char *ListenAddresses;
+extern PGDLLIMPORT int	Unix_socket_permissions;
+extern PGDLLIMPORT char *Unix_socket_group;
+extern PGDLLIMPORT char *Unix_socket_directories;
+extern PGDLLIMPORT char *ListenAddresses;
 extern bool ClientAuthInProgress;
-extern int	PreAuthDelay;
-extern int	AuthenticationTimeout;
-extern bool Log_connections;
-extern bool log_hostname;
-extern bool enable_bonjour;
-extern char *bonjour_name;
-extern bool restart_after_crash;
-extern bool remove_temp_files_after_crash;
+extern PGDLLIMPORT int	PreAuthDelay;
+extern PGDLLIMPORT int	AuthenticationTimeout;
+extern PGDLLIMPORT bool Log_connections;
+extern PGDLLIMPORT bool log_hostname;
+extern PGDLLIMPORT bool enable_bonjour;
+extern PGDLLIMPORT char *bonjour_name;
+extern PGDLLIMPORT bool restart_after_crash;
+extern PGDLLIMPORT bool remove_temp_files_after_crash;
 
 #ifdef WIN32
 extern HANDLE PostmasterHandle;
diff --git a/src/include/postmaster/syslogger.h b/src/include/postmaster/syslogger.h
index 1491eecb0f..9dde75321c 100644
--- a/src/include/postmaster/syslogger.h
+++ b/src/include/postmaster/syslogger.h
@@ -62,13 +62,13 @@ typedef union
 
 
 /* GUC options */
-extern bool Logging_collector;
-extern int	Log_RotationAge;
-extern int	Log_RotationSize;
+extern PGDLLIMPORT bool Logging_collector;
+extern PGDLLIMPORT int	Log_RotationAge;
+extern PGDLLIMPORT int	Log_RotationSize;
 extern PGDLLIMPORT char *Log_directory;
 extern PGDLLIMPORT char *Log_filename;
-extern bool Log_truncate_on_rotation;
-extern int	Log_file_mode;
+extern PGDLLIMPORT bool Log_truncate_on_rotation;
+extern PGDLLIMPORT int	Log_file_mode;
 
 #ifndef WIN32
 extern int	syslogPipe[2];
diff --git a/src/include/postmaster/walwriter.h b/src/include/postmaster/walwriter.h
index 3ccc332333..e4cb844ea1 100644
--- a/src/include/postmaster/walwriter.h
+++ b/src/include/postmaster/walwriter.h
@@ -13,8 +13,8 @@
 #define _WALWRITER_H
 
 /* GUC options */
-extern int	WalWriterDelay;
-extern int	WalWriterFlushAfter;
+extern PGDLLIMPORT int	WalWriterDelay;
+extern PGDLLIMPORT int	WalWriterFlushAfter;
 
 extern void WalWriterMain(void) pg_attribute_noreturn();
 
diff --git a/src/include/replication/logicallauncher.h b/src/include/replication/logicallauncher.h
index 301e494f7b..2c6f71e129 100644
--- a/src/include/replication/logicallauncher.h
+++ b/src/include/replication/logicallauncher.h
@@ -12,8 +12,8 @@
 #ifndef LOGICALLAUNCHER_H
 #define LOGICALLAUNCHER_H
 
-extern int	max_logical_replication_workers;
-extern int	max_sync_workers_per_subscription;
+extern PGDLLIMPORT int	max_logical_replication_workers;
+extern PGDLLIMPORT int	max_sync_workers_per_subscription;
 
 extern void ApplyLauncherRegister(void);
 extern void ApplyLauncherMain(Datum main_arg);
diff --git a/src/include/replication/syncrep.h b/src/include/replication/syncrep.h
index 4266afde8b..b4324810a4 100644
--- a/src/include/replication/syncrep.h
+++ b/src/include/replication/syncrep.h
@@ -79,7 +79,7 @@ extern SyncRepConfigData *syncrep_parse_result;
 extern char *syncrep_parse_error_msg;
 
 /* user-settable parameters for synchronous replication */
-extern char *SyncRepStandbyNames;
+extern PGDLLIMPORT char *SyncRepStandbyNames;
 
 /* called by user backend */
 extern void SyncRepWaitForLSN(XLogRecPtr lsn, bool commit);
diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h
index 0b607ed777..3385c79b92 100644
--- a/src/include/replication/walreceiver.h
+++ b/src/include/replication/walreceiver.h
@@ -25,9 +25,9 @@
 #include "utils/tuplestore.h"
 
 /* user-settable parameters */
-extern int	wal_receiver_status_interval;
-extern int	wal_receiver_timeout;
-extern bool hot_standby_feedback;
+extern PGDLLIMPORT int	wal_receiver_status_interval;
+extern PGDLLIMPORT int	wal_receiver_timeout;
+extern PGDLLIMPORT bool hot_standby_feedback;
 
 /*
  * MAXCONNINFO: maximum size of a connection string.
diff --git a/src/include/replication/walsender.h b/src/include/replication/walsender.h
index 828106933c..d6618495a0 100644
--- a/src/include/replication/walsender.h
+++ b/src/include/replication/walsender.h
@@ -31,9 +31,9 @@ extern bool am_db_walsender;
 extern bool wake_wal_senders;
 
 /* user-settable parameters */
-extern int	max_wal_senders;
-extern int	wal_sender_timeout;
-extern bool log_replication_commands;
+extern PGDLLIMPORT int	max_wal_senders;
+extern PGDLLIMPORT int	wal_sender_timeout;
+extern PGDLLIMPORT bool log_replication_commands;
 
 extern void InitWalSender(void);
 extern bool exec_replication_command(const char *query_string);
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h
index cfce23ecbc..31c67a0065 100644
--- a/src/include/storage/bufmgr.h
+++ b/src/include/storage/bufmgr.h
@@ -65,16 +65,16 @@ struct SMgrRelationData;
 extern PGDLLIMPORT int NBuffers;
 
 /* in bufmgr.c */
-extern bool zero_damaged_pages;
-extern int	bgwriter_lru_maxpages;
-extern double bgwriter_lru_multiplier;
-extern bool track_io_timing;
-extern int	effective_io_concurrency;
-extern int	maintenance_io_concurrency;
-
-extern int	checkpoint_flush_after;
-extern int	backend_flush_after;
-extern int	bgwriter_flush_after;
+extern PGDLLIMPORT bool zero_damaged_pages;
+extern PGDLLIMPORT int	bgwriter_lru_maxpages;
+extern PGDLLIMPORT double bgwriter_lru_multiplier;
+extern PGDLLIMPORT bool track_io_timing;
+extern PGDLLIMPORT int	effective_io_concurrency;
+extern PGDLLIMPORT int	maintenance_io_concurrency;
+
+extern PGDLLIMPORT int	checkpoint_flush_after;
+extern PGDLLIMPORT int	backend_flush_after;
+extern PGDLLIMPORT int	bgwriter_flush_after;
 
 /* in buf_init.c */
 extern PGDLLIMPORT char *BufferBlocks;
diff --git a/src/include/storage/dsm_impl.h b/src/include/storage/dsm_impl.h
index ff72f7b0e5..5fc38b5e25 100644
--- a/src/include/storage/dsm_impl.h
+++ b/src/include/storage/dsm_impl.h
@@ -39,8 +39,8 @@
 #endif
 
 /* GUC. */
-extern int	dynamic_shared_memory_type;
-extern int	min_dynamic_shared_memory;
+extern PGDLLIMPORT int	dynamic_shared_memory_type;
+extern PGDLLIMPORT int	min_dynamic_shared_memory;
 
 /*
  * Directory for on-disk state.
diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h
index 34602ae006..8f4d08e6a1 100644
--- a/src/include/storage/fd.h
+++ b/src/include/storage/fd.h
@@ -59,7 +59,7 @@ typedef int File;
 /* GUC parameter */
 extern PGDLLIMPORT int max_files_per_process;
 extern PGDLLIMPORT bool data_sync_retry;
-extern int	recovery_init_sync_method;
+extern PGDLLIMPORT int	recovery_init_sync_method;
 
 /*
  * This is private to fd.c, but exported for save/restore_backend_variables()
diff --git a/src/include/storage/large_object.h b/src/include/storage/large_object.h
index ae1e2482ea..6e72b17a1b 100644
--- a/src/include/storage/large_object.h
+++ b/src/include/storage/large_object.h
@@ -79,7 +79,7 @@ typedef struct LargeObjectDesc
 /*
  * GUC: backwards-compatibility flag to suppress LO permission checks
  */
-extern bool lo_compat_privileges;
+extern PGDLLIMPORT bool lo_compat_privileges;
 
 /*
  * Function definitions...
diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h
index 9b2a421c32..0c7929251d 100644
--- a/src/include/storage/lock.h
+++ b/src/include/storage/lock.h
@@ -34,14 +34,14 @@ typedef struct PROC_QUEUE
 } PROC_QUEUE;
 
 /* GUC variables */
-extern int	max_locks_per_xact;
+extern PGDLLIMPORT int	max_locks_per_xact;
 
 #ifdef LOCK_DEBUG
-extern int	Trace_lock_oidmin;
-extern bool Trace_locks;
-extern bool Trace_userlocks;
-extern int	Trace_lock_table;
-extern bool Debug_deadlocks;
+extern PGDLLIMPORT int	Trace_lock_oidmin;
+extern PGDLLIMPORT bool Trace_locks;
+extern PGDLLIMPORT bool Trace_userlocks;
+extern PGDLLIMPORT int	Trace_lock_table;
+extern PGDLLIMPORT bool Debug_deadlocks;
 #endif							/* LOCK_DEBUG */
 
 
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index a8f052e484..00dba0f720 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -110,7 +110,7 @@ typedef enum LWLockMode
 
 
 #ifdef LOCK_DEBUG
-extern bool Trace_lwlocks;
+extern PGDLLIMPORT bool Trace_lwlocks;
 #endif
 
 extern bool LWLockAcquire(LWLock *lock, LWLockMode mode);
diff --git a/src/include/storage/pg_shmem.h b/src/include/storage/pg_shmem.h
index 059df1b72c..6823538299 100644
--- a/src/include/storage/pg_shmem.h
+++ b/src/include/storage/pg_shmem.h
@@ -42,9 +42,9 @@ typedef struct PGShmemHeader	/* standard header for all Postgres shmem */
 } PGShmemHeader;
 
 /* GUC variables */
-extern int	shared_memory_type;
-extern int	huge_pages;
-extern int	huge_page_size;
+extern PGDLLIMPORT int	shared_memory_type;
+extern PGDLLIMPORT int	huge_pages;
+extern PGDLLIMPORT int	huge_page_size;
 
 /* Possible values for huge_pages */
 typedef enum
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index 152b698611..bf0afbf181 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -22,9 +22,9 @@
 /*
  * GUC variables
  */
-extern int	max_predicate_locks_per_xact;
-extern int	max_predicate_locks_per_relation;
-extern int	max_predicate_locks_per_page;
+extern PGDLLIMPORT int	max_predicate_locks_per_xact;
+extern PGDLLIMPORT int	max_predicate_locks_per_relation;
+extern PGDLLIMPORT int	max_predicate_locks_per_page;
 
 
 /* Number of SLRU buffers to use for Serial SLRU */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index be67d8a861..f9fd7572d6 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -382,7 +382,7 @@ extern PGDLLIMPORT int StatementTimeout;
 extern PGDLLIMPORT int LockTimeout;
 extern PGDLLIMPORT int IdleInTransactionSessionTimeout;
 extern PGDLLIMPORT int IdleSessionTimeout;
-extern bool log_lock_waits;
+extern PGDLLIMPORT bool log_lock_waits;
 
 
 /*
diff --git a/src/include/storage/standby.h b/src/include/storage/standby.h
index 38fd85a431..3c78d76c93 100644
--- a/src/include/storage/standby.h
+++ b/src/include/storage/standby.h
@@ -21,10 +21,10 @@
 #include "storage/standbydefs.h"
 
 /* User-settable GUC parameters */
-extern int	vacuum_defer_cleanup_age;
-extern int	max_standby_archive_delay;
-extern int	max_standby_streaming_delay;
-extern bool log_recovery_conflict_waits;
+extern PGDLLIMPORT int	vacuum_defer_cleanup_age;
+extern PGDLLIMPORT int	max_standby_archive_delay;
+extern PGDLLIMPORT int	max_standby_streaming_delay;
+extern PGDLLIMPORT bool log_recovery_conflict_waits;
 
 extern void InitRecoveryTransactionEnvironment(void);
 extern void ShutdownRecoveryTransactionEnvironment(void);
diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h
index 968345404e..a3a7c5cada 100644
--- a/src/include/tcop/tcopprot.h
+++ b/src/include/tcop/tcopprot.h
@@ -27,9 +27,9 @@
 
 extern CommandDest whereToSendOutput;
 extern PGDLLIMPORT const char *debug_query_string;
-extern int	max_stack_depth;
-extern int	PostAuthDelay;
-extern int	client_connection_check_interval;
+extern PGDLLIMPORT int	max_stack_depth;
+extern PGDLLIMPORT int	PostAuthDelay;
+extern PGDLLIMPORT int	client_connection_check_interval;
 
 /* GUC-configurable parameters */
 
diff --git a/src/include/tsearch/ts_cache.h b/src/include/tsearch/ts_cache.h
index 888f7028b1..71e05509d6 100644
--- a/src/include/tsearch/ts_cache.h
+++ b/src/include/tsearch/ts_cache.h
@@ -84,7 +84,7 @@ typedef struct
 /*
  * GUC variable for current configuration
  */
-extern char *TSCurrentConfig;
+extern PGDLLIMPORT char *TSCurrentConfig;
 
 
 extern TSParserCacheEntry *lookup_ts_parser_cache(Oid prsId);
diff --git a/src/include/utils/array.h b/src/include/utils/array.h
index 4ae6c3be2f..798e34cc67 100644
--- a/src/include/utils/array.h
+++ b/src/include/utils/array.h
@@ -339,7 +339,7 @@ typedef struct ArrayIteratorData *ArrayIterator;
 /*
  * GUC parameter
  */
-extern bool Array_nulls;
+extern PGDLLIMPORT bool Array_nulls;
 
 /*
  * prototypes for functions defined in arrayfuncs.c
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 40fcb0ab6d..ee5335b7c5 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -65,7 +65,7 @@ extern char *regexp_fixed_prefix(text *text_re, bool case_insensitive,
 								 Oid collation, bool *exact);
 
 /* ruleutils.c */
-extern bool quote_all_identifiers;
+extern PGDLLIMPORT bool quote_all_identifiers;
 extern const char *quote_identifier(const char *ident);
 extern char *quote_qualified_identifier(const char *qualifier,
 										const char *ident);
diff --git a/src/include/utils/bytea.h b/src/include/utils/bytea.h
index eb9df9e4f7..8ab96920ec 100644
--- a/src/include/utils/bytea.h
+++ b/src/include/utils/bytea.h
@@ -22,6 +22,6 @@ typedef enum
 	BYTEA_OUTPUT_HEX
 }			ByteaOutputType;
 
-extern int	bytea_output;		/* ByteaOutputType, but int for GUC enum */
+extern PGDLLIMPORT int	bytea_output;		/* ByteaOutputType, but int for GUC enum */
 
 #endif							/* BYTEA_H */
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index f53607e12e..0a4dc7473d 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -424,12 +424,12 @@ typedef enum
 	PGERROR_VERBOSE				/* all the facts, ma'am */
 }			PGErrorVerbosity;
 
-extern int	Log_error_verbosity;
-extern char *Log_line_prefix;
+extern PGDLLIMPORT int	Log_error_verbosity;
+extern PGDLLIMPORT char *Log_line_prefix;
 extern int	Log_destination;
-extern char *Log_destination_string;
-extern bool syslog_sequence_numbers;
-extern bool syslog_split_messages;
+extern PGDLLIMPORT char *Log_destination_string;
+extern PGDLLIMPORT bool syslog_sequence_numbers;
+extern PGDLLIMPORT bool syslog_split_messages;
 
 /* Log destination bitmap */
 #define LOG_DESTINATION_STDERR	 1
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index a7c3a4958e..76e1127757 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -233,53 +233,53 @@ typedef enum
 
 
 /* GUC vars that are actually declared in guc.c, rather than elsewhere */
-extern bool Debug_print_plan;
-extern bool Debug_print_parse;
-extern bool Debug_print_rewritten;
-extern bool Debug_pretty_print;
+extern PGDLLIMPORT bool Debug_print_plan;
+extern PGDLLIMPORT bool Debug_print_parse;
+extern PGDLLIMPORT bool Debug_print_rewritten;
+extern PGDLLIMPORT bool Debug_pretty_print;
 
-extern bool log_parser_stats;
-extern bool log_planner_stats;
-extern bool log_executor_stats;
-extern bool log_statement_stats;
-extern bool log_btree_build_stats;
+extern PGDLLIMPORT bool log_parser_stats;
+extern PGDLLIMPORT bool log_planner_stats;
+extern PGDLLIMPORT bool log_executor_stats;
+extern PGDLLIMPORT bool log_statement_stats;
+extern PGDLLIMPORT bool log_btree_build_stats;
 
 extern PGDLLIMPORT bool check_function_bodies;
-extern bool session_auth_is_superuser;
+extern PGDLLIMPORT bool session_auth_is_superuser;
 
-extern bool log_duration;
-extern int	log_parameter_max_length;
-extern int	log_parameter_max_length_on_error;
-extern int	log_min_error_statement;
+extern PGDLLIMPORT bool log_duration;
+extern PGDLLIMPORT int	log_parameter_max_length;
+extern PGDLLIMPORT int	log_parameter_max_length_on_error;
+extern PGDLLIMPORT int	log_min_error_statement;
 extern PGDLLIMPORT int log_min_messages;
 extern PGDLLIMPORT int client_min_messages;
-extern int	log_min_duration_sample;
-extern int	log_min_duration_statement;
-extern int	log_temp_files;
-extern double log_statement_sample_rate;
-extern double log_xact_sample_rate;
-extern char *backtrace_functions;
+extern PGDLLIMPORT int	log_min_duration_sample;
+extern PGDLLIMPORT int	log_min_duration_statement;
+extern PGDLLIMPORT int	log_temp_files;
+extern PGDLLIMPORT double log_statement_sample_rate;
+extern PGDLLIMPORT double log_xact_sample_rate;
+extern PGDLLIMPORT char *backtrace_functions;
 extern char *backtrace_symbol_list;
 
-extern int	temp_file_limit;
+extern PGDLLIMPORT int	temp_file_limit;
 
-extern int	num_temp_buffers;
+extern PGDLLIMPORT int	num_temp_buffers;
 
-extern char *cluster_name;
+extern PGDLLIMPORT char *cluster_name;
 extern PGDLLIMPORT char *ConfigFileName;
-extern char *HbaFileName;
-extern char *IdentFileName;
-extern char *external_pid_file;
+extern PGDLLIMPORT char *HbaFileName;
+extern PGDLLIMPORT char *IdentFileName;
+extern PGDLLIMPORT char *external_pid_file;
 
 extern PGDLLIMPORT char *application_name;
 
-extern int	tcp_keepalives_idle;
-extern int	tcp_keepalives_interval;
-extern int	tcp_keepalives_count;
-extern int	tcp_user_timeout;
+extern PGDLLIMPORT int	tcp_keepalives_idle;
+extern PGDLLIMPORT int	tcp_keepalives_interval;
+extern PGDLLIMPORT int	tcp_keepalives_count;
+extern PGDLLIMPORT int	tcp_user_timeout;
 
 #ifdef TRACE_SORT
-extern bool trace_sort;
+extern PGDLLIMPORT bool trace_sort;
 #endif
 
 /*
diff --git a/src/include/utils/pg_locale.h b/src/include/utils/pg_locale.h
index 2946f46c76..d3f931c230 100644
--- a/src/include/utils/pg_locale.h
+++ b/src/include/utils/pg_locale.h
@@ -36,10 +36,10 @@
 
 
 /* GUC settings */
-extern char *locale_messages;
-extern char *locale_monetary;
-extern char *locale_numeric;
-extern char *locale_time;
+extern PGDLLIMPORT char *locale_messages;
+extern PGDLLIMPORT char *locale_monetary;
+extern PGDLLIMPORT char *locale_numeric;
+extern PGDLLIMPORT char *locale_time;
 
 /* lc_time localization cache */
 extern char *localized_abbrev_days[];
diff --git a/src/include/utils/plancache.h b/src/include/utils/plancache.h
index ff09c63a02..caab48ee9f 100644
--- a/src/include/utils/plancache.h
+++ b/src/include/utils/plancache.h
@@ -35,7 +35,7 @@ typedef enum
 }			PlanCacheMode;
 
 /* GUC parameter */
-extern int	plan_cache_mode;
+extern PGDLLIMPORT int	plan_cache_mode;
 
 #define CACHEDPLANSOURCE_MAGIC		195726186
 #define CACHEDPLAN_MAGIC			953717834
diff --git a/src/include/utils/ps_status.h b/src/include/utils/ps_status.h
index 9f43e1fdf0..bba463591f 100644
--- a/src/include/utils/ps_status.h
+++ b/src/include/utils/ps_status.h
@@ -12,7 +12,7 @@
 #ifndef PS_STATUS_H
 #define PS_STATUS_H
 
-extern bool update_process_title;
+extern PGDLLIMPORT bool update_process_title;
 
 extern char **save_ps_display_args(int argc, char **argv);
 
diff --git a/src/include/utils/queryjumble.h b/src/include/utils/queryjumble.h
index 7af6652f3e..a0107f020a 100644
--- a/src/include/utils/queryjumble.h
+++ b/src/include/utils/queryjumble.h
@@ -61,7 +61,7 @@ enum ComputeQueryIdType
 };
 
 /* GUC parameters */
-extern int	compute_query_id;
+extern PGDLLIMPORT int	compute_query_id;
 
 
 extern const char *CleanQuerytext(const char *query, int *location, int *len);
diff --git a/src/include/utils/rls.h b/src/include/utils/rls.h
index 46b32347c3..175c24633c 100644
--- a/src/include/utils/rls.h
+++ b/src/include/utils/rls.h
@@ -14,7 +14,7 @@
 #define RLS_H
 
 /* GUC variable */
-extern bool row_security;
+extern PGDLLIMPORT bool row_security;
 
 /*
  * Used by callers of check_enable_rls.
diff --git a/src/include/utils/xml.h b/src/include/utils/xml.h
index d79668f3c4..95dda63b10 100644
--- a/src/include/utils/xml.h
+++ b/src/include/utils/xml.h
@@ -75,9 +75,9 @@ extern char *map_sql_identifier_to_xml_name(const char *ident, bool fully_escape
 extern char *map_xml_name_to_sql_identifier(const char *name);
 extern char *map_sql_value_to_xml_value(Datum value, Oid type, bool xml_escape_strings);
 
-extern int	xmlbinary;			/* XmlBinaryType, but int for guc enum */
+extern PGDLLIMPORT int	xmlbinary;			/* XmlBinaryType, but int for guc enum */
 
-extern int	xmloption;			/* XmlOptionType, but int for guc enum */
+extern PGDLLIMPORT int	xmloption;			/* XmlOptionType, but int for guc enum */
 
 extern const TableFuncRoutine XmlTableRoutine;
 
-- 
2.32.0

Reply via email to