Skip to content

Commit 5c2ff72

Browse files
authored
GH-50978: [C++] Enable MSVC's new preprocessor to handle C++20 grammar (#50979)
### Rationale for this change Try to use MSVC's new preprocessor to handle C++20 grammar such as `__VA_OPT__`. ### What changes are included in this PR? Change the common flag under MSVC. ### Are these changes tested? Tested by existed tests. ### Are there any user-facing changes? No. * GitHub Issue: #50978 Authored-by: Zehua Zou <zehuazou2000@gmail.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent 911a7cb commit 5c2ff72

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

‎cpp/cmake_modules/SetupCxxFlags.cmake‎

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -218,22 +218,11 @@ if(WIN32)
218218
set(CXX_COMMON_FLAGS "/W3 /EHsc")
219219
endif()
220220

221-
# Disable C5105 (macro expansion producing 'defined' has undefined
222-
# behavior) warning because there are codes that produce this
223-
# warning in Windows Kits. e.g.:
224-
#
225-
# #define _CRT_INTERNAL_NONSTDC_NAMES \
226-
# ( \
227-
# ( defined _CRT_DECLARE_NONSTDC_NAMES && _CRT_DECLARE_NONSTDC_NAMES) || \
228-
# (!defined _CRT_DECLARE_NONSTDC_NAMES && !__STDC__ ) \
229-
# )
221+
# Enable the conforming preprocessor to support C++20 features.
230222
#
231223
# See also:
232-
# * C5105: https://docs.microsoft.com/en-US/cpp/error-messages/compiler-warnings/c5105
233-
# * Related reports:
234-
# * https://developercommunity.visualstudio.com/content/problem/387684/c5105-with-stdioh-and-experimentalpreprocessor.html
235-
# * https://developercommunity.visualstudio.com/content/problem/1249671/stdc17-generates-warning-compiling-windowsh.html
236-
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} /wd5105")
224+
# * https://devblogs.microsoft.com/cppblog/announcing-full-support-for-a-c-c-conformant-preprocessor-in-msvc/
225+
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} /Zc:preprocessor")
237226

238227
if(ARROW_USE_STATIC_CRT)
239228
foreach(c_flag

0 commit comments

Comments
 (0)