[PATCH] Fix type redefinition build errors with macOS SDK 15.0 - Mailing list pgsql-hackers

From Stan Hu
Subject [PATCH] Fix type redefinition build errors with macOS SDK 15.0
Date
Msg-id 4edd2d3c30429c4445cc805ae9a788c489856eb7.1719265762.git.stanhu@gmail.com
Whole thread Raw
Responses [PATCH] Fix type redefinition build errors with macOS SDK 15.0
List pgsql-hackers
Prior to macOS SDK 15, there were include guards in
$SDK_ROOT/usr/include/xlocale/_regex.h:

  #ifndef _REGEX_H_
  #include <_regex.h>
  #endif // _REGEX_H_
  #include <_xlocale.h>

In macOS SDK 15.5, these include guards are gone:

  #include <_regex.h>
  #include <_xlocale.h>

Because _REGEX_H_ was defined locally in PostgreSQL's version of
src/include/regex/regex.h, these include guards prevented duplicate
definitions from $SDK_ROOT/usr/include/_regex.h (not to be confused
with $SDK_ROOT/usr/include/xlocale/_regex.h).

To fix this build issue, define __REGEX_H_ to prevent macOS from
including the header that contain redefinitions of the local regex
structures.

Discussion:
https://www.postgresql.org/message-id/CAMBWrQ%3DF9SSPfsFtCv%3DJT51WGK2VcgLA%2BiiJJOmjN0zbbufOEA%40mail.gmail.com
---
 src/include/regex/regex.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/include/regex/regex.h b/src/include/regex/regex.h
index d08113724f..045ac626cc 100644
--- a/src/include/regex/regex.h
+++ b/src/include/regex/regex.h
@@ -32,6 +32,20 @@
  * src/include/regex/regex.h
  */
 
+#if defined(__darwin__)
+/*
+ * mmacOS SDK 15.0 removed the _REGEX_H_ include guards in
+ * $SDK_ROOT/usr/include/xlocale/_regex.h, so now
+ * $SDK_ROOT/usr/include/_regex.h is always included. That file defines
+ * the same types as below. To guard against type redefinition errors,
+ * define __REGEX_H_.
+ */
+#ifndef __REGEX_H_
+#define __REGEX_H_
+
+#endif                            /* __REGEX_H_ */
+#endif
+
 /*
  * Add your own defines, if needed, here.
  */
-- 
2.45.0




pgsql-hackers by date:

Previous
From: Jelte Fennema-Nio
Date:
Subject: Re: RFC: Additional Directory for Extensions
Next
From: Nathan Bossart
Date:
Subject: Re: improve predefined roles documentation