Skip to content

Commit

Permalink
GH-38709: [C++] Protect against PREALLOCATE preprocessor defined on m…
Browse files Browse the repository at this point in the history
…acOS (#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 <Christian.Holm.Christensen@cern.ch>
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
cholmcc and kou committed Nov 29, 2023
1 parent d662bef commit 61a4a80
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cpp/src/arrow/compute/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down

0 comments on commit 61a4a80

Please sign in to comment.