This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 5c2ff723410 GH-50978: [C++] Enable MSVC's new preprocessor to handle 
C++20 grammar (#50979)
5c2ff723410 is described below

commit 5c2ff723410f0841b0ea1158d455bbfa23ff1ca9
Author: Zehua Zou <[email protected]>
AuthorDate: Tue Sep 22 05:13:32 2026 +0800

    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 <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 cpp/cmake_modules/SetupCxxFlags.cmake | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake 
b/cpp/cmake_modules/SetupCxxFlags.cmake
index f6590ddce68..e7a4a3e5dc8 100644
--- a/cpp/cmake_modules/SetupCxxFlags.cmake
+++ b/cpp/cmake_modules/SetupCxxFlags.cmake
@@ -218,22 +218,11 @@ if(WIN32)
       set(CXX_COMMON_FLAGS "/W3 /EHsc")
     endif()
 
-    # Disable C5105 (macro expansion producing 'defined' has undefined
-    # behavior) warning because there are codes that produce this
-    # warning in Windows Kits. e.g.:
-    #
-    #   #define _CRT_INTERNAL_NONSTDC_NAMES                                    
        \
-    #        (                                                                 
         \
-    #            ( defined _CRT_DECLARE_NONSTDC_NAMES && 
_CRT_DECLARE_NONSTDC_NAMES) || \
-    #            (!defined _CRT_DECLARE_NONSTDC_NAMES && !__STDC__             
    )    \
-    #        )
+    # Enable the conforming preprocessor to support C++20 features.
     #
     # See also:
-    # * C5105: 
https://docs.microsoft.com/en-US/cpp/error-messages/compiler-warnings/c5105
-    # * Related reports:
-    #   * 
https://developercommunity.visualstudio.com/content/problem/387684/c5105-with-stdioh-and-experimentalpreprocessor.html
-    #   * 
https://developercommunity.visualstudio.com/content/problem/1249671/stdc17-generates-warning-compiling-windowsh.html
-    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} /wd5105")
+    # * 
https://devblogs.microsoft.com/cppblog/announcing-full-support-for-a-c-c-conformant-preprocessor-in-msvc/
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} /Zc:preprocessor")
 
     if(ARROW_USE_STATIC_CRT)
       foreach(c_flag

Reply via email to