[m-rev.] diff: avoid redefining some macros

Julien Fischer jfischer at opturion.com
Fri Jan 14 19:27:47 AEDT 2022


Avoid redefining some macros.

util/mkinit.c:
     Do not define _BSD_SOURCE or _DEFAULT_SOURCE if the user
     has already done so.  (This affects compilation of extras/net
     when the C compiler is set to treat redefined macros as an error.)

Julien.

diff --git a/util/mkinit.c b/util/mkinit.c
index 8b46b95..4629a14 100644
--- a/util/mkinit.c
+++ b/util/mkinit.c
@@ -305,8 +305,12 @@ static const char header1[] =
  // the deprecated macro about for compatibility with older versions of glibc.
  static const char header2[] =
      "*/\n"
-    "#define _DEFAULT_SOURCE\n"
-    "#define _BSD_SOURCE\n"
+    "#ifndef _DEFAULT_SOURCE\n"
+    "  #define _DEFAULT_SOURCE\n"
+    "#endif\n"
+    "#ifndef _BSD_SOURCE\n"
+    "  #define _BSD_SOURCE\n"
+    "#endif\n"
      "#include <stddef.h>\n"
      "#ifdef MR_PROFILE_SBRK\n"
      "#include <unistd.h>\n"


More information about the reviews mailing list