Skip to content

Commit 8fd9bb1

Browse files
committed
Enable MSVC conforming preprocessor
Switch MSVC to use the conforming preprocessor, using the /Zc:preprocessor option. This allows us to drop the alternative implementation of VA_ARGS_NARGS() for the previous "traditional" preprocessor. This also prepares the way for enabling C11 mode in the future, which enables the conforming preprocessor by default. This now requires Visual Studio 2019. The installation documentation is adjusted accordingly. Discussion: https://www.postgresql.org/message-id/flat/01a69441-af54-4822-891b-ca28e05b215a%40eisentraut.org
1 parent 7320611 commit 8fd9bb1

File tree

3 files changed

+6
-25
lines changed

3 files changed

+6
-25
lines changed

doc/src/sgml/installation.sgml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3847,17 +3847,13 @@ make: *** [postgres] Error 1
38473847
<para>
38483848
Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
38493849
32-bit PostgreSQL builds are possible with
3850-
<productname>Visual Studio 2015</productname> to
3850+
<productname>Visual Studio 2019</productname> to
38513851
<productname>Visual Studio 2022</productname>,
38523852
as well as standalone Windows SDK releases 10 and above.
38533853
64-bit PostgreSQL builds are supported with
38543854
<productname>Microsoft Windows SDK</productname> version 10 and above or
3855-
<productname>Visual Studio 2015</productname> and above.
3855+
<productname>Visual Studio 2019</productname> and above.
38563856
<!--
3857-
For 2015 requirements:
3858-
https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2015-sysrequirements-vs
3859-
For 2017 requirements:
3860-
https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2017-system-requirements-vs
38613857
For 2019 requirements:
38623858
https://docs.microsoft.com/en-us/visualstudio/releases/2019/system-requirements
38633859
For 2022 requirements:

meson.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ elif host_system == 'windows'
279279
# define before including <time.h> for getting localtime_r() etc. on MinGW
280280
cppflags += '-D_POSIX_C_SOURCE'
281281
endif
282+
if cc.get_id() == 'msvc'
283+
# required for VA_ARGS_NARGS() in c.h; requires VS 2019
284+
cppflags += '/Zc:preprocessor'
285+
endif
282286

283287
export_file_format = 'win'
284288
export_file_suffix = 'def'

src/include/c.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -376,25 +376,7 @@
376376
* pretty trivial: VA_ARGS_NARGS_() returns its 64th argument, and we set up
377377
* the call so that that is the appropriate one of the list of constants.
378378
* This idea is due to Laurent Deniau.
379-
*
380-
* MSVC has an implementation of __VA_ARGS__ that doesn't conform to the
381-
* standard unless you use the /Zc:preprocessor compiler flag, but that
382-
* isn't available before Visual Studio 2019. For now, use a different
383-
* definition that also works on older compilers.
384379
*/
385-
#ifdef _MSC_VER
386-
#define EXPAND(args) args
387-
#define VA_ARGS_NARGS(...) \
388-
VA_ARGS_NARGS_ EXPAND((__VA_ARGS__, \
389-
63,62,61,60, \
390-
59,58,57,56,55,54,53,52,51,50, \
391-
49,48,47,46,45,44,43,42,41,40, \
392-
39,38,37,36,35,34,33,32,31,30, \
393-
29,28,27,26,25,24,23,22,21,20, \
394-
19,18,17,16,15,14,13,12,11,10, \
395-
9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
396-
#else
397-
398380
#define VA_ARGS_NARGS(...) \
399381
VA_ARGS_NARGS_(__VA_ARGS__, \
400382
63,62,61,60, \
@@ -404,7 +386,6 @@
404386
29,28,27,26,25,24,23,22,21,20, \
405387
19,18,17,16,15,14,13,12,11,10, \
406388
9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
407-
#endif
408389

409390
#define VA_ARGS_NARGS_( \
410391
_01,_02,_03,_04,_05,_06,_07,_08,_09,_10, \

0 commit comments

Comments
 (0)