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 61a4a80377 GH-38709: [C++] Protect against PREALLOCATE preprocessor 
defined on macOS (#38760)
61a4a80377 is described below

commit 61a4a803779db17a6c7bd57210e0dc92a067f2a0
Author: Christian Holm Christensen <[email protected]>
AuthorDate: Wed Nov 29 03:41:37 2023 +0100

    GH-38709: [C++] Protect against PREALLOCATE preprocessor defined on macOS 
(#38760)
    
    ### Rationale for this change
    
    The macOS header `sys/vnode.h` defines `PREALLOCATE` as a preprocessor 
macro, which causes a conflict in `arrow/compute/kernel.h` where the same name 
is defined as an identifier.
    
    Other BSDs does not seem to define this macro.
    
    ### What changes are included in this PR?
    
    `#undef PREALLOCATE` on macOS and if defined.
    
    ### Are these changes tested?
    
    Somewhat, in a different context.
    
    ### Are there any user-facing changes?
    
    If some code specific to macOS actually uses the `PREALLOCATE` macro, then 
that code may have problems.  However, it is unlikely that any user code would 
use this macro as it seems to be intended for internal use in the BSD kernel of 
macOS.
    
    * Closes: #38709
    
    Lead-authored-by: Christian Holm Christensen 
<[email protected]>
    Co-authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 cpp/src/arrow/compute/kernel.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/cpp/src/arrow/compute/kernel.h b/cpp/src/arrow/compute/kernel.h
index 5b5b5718e1..1adb3e96c9 100644
--- a/cpp/src/arrow/compute/kernel.h
+++ b/cpp/src/arrow/compute/kernel.h
@@ -38,6 +38,12 @@
 #include "arrow/util/macros.h"
 #include "arrow/util/visibility.h"
 
+// macOS defines PREALLOCATE as a preprocessor macro in the header sys/vnode.h.
+// No other BSD seems to do so. The name is used as an identifier in 
MemAllocation enum.
+#if defined(__APPLE__) && defined(PREALLOCATE)
+#undef PREALLOCATE
+#endif
+
 namespace arrow {
 namespace compute {
 

Reply via email to