From: Elias Naur Date: Wed, 7 Mar 2018 17:23:21 +0000 (+0100) Subject: runtime/cgo: make sure nil is undefined before defining it X-Git-Tag: go1.11beta1~1303 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7a2a96d6ad75762f427669beb0220810adb6a9e1;p=gostls13.git runtime/cgo: make sure nil is undefined before defining it While working on standalone builds of gomobile bindings, I ran into errors on the form: gcc_darwin_arm.c:30:31: error: ambiguous expansion of macro 'nil' [-Werror,-Wambiguous-macro] /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk/usr/include/MacTypes.h:94:15: note: expanding this definition of 'nil' Fix it by undefining nil before defining it in libcgo.h. Change-Id: I8e9660a68c6c351e592684d03d529f0d182c0493 Reviewed-on: https://go-review.googlesource.com/99215 Run-TryBot: Elias Naur TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- diff --git a/src/runtime/cgo/gcc_darwin_arm.c b/src/runtime/cgo/gcc_darwin_arm.c index e2f96e9dc8..30fca9902a 100644 --- a/src/runtime/cgo/gcc_darwin_arm.c +++ b/src/runtime/cgo/gcc_darwin_arm.c @@ -9,12 +9,12 @@ #include #include -#include "libcgo.h" -#include "libcgo_unix.h" - #include #include +#include "libcgo.h" +#include "libcgo_unix.h" + #define magic (0xe696c4f4U) // inittls allocates a thread-local storage slot for g. diff --git a/src/runtime/cgo/gcc_darwin_arm64.c b/src/runtime/cgo/gcc_darwin_arm64.c index 25106b75a5..5c483b1845 100644 --- a/src/runtime/cgo/gcc_darwin_arm64.c +++ b/src/runtime/cgo/gcc_darwin_arm64.c @@ -10,12 +10,12 @@ #include #include -#include "libcgo.h" -#include "libcgo_unix.h" - #include #include +#include "libcgo.h" +#include "libcgo_unix.h" + #define magic (0xc476c475c47957UL) // inittls allocates a thread-local storage slot for g. diff --git a/src/runtime/cgo/libcgo.h b/src/runtime/cgo/libcgo.h index 2b8b4e25a2..c38fb643ff 100644 --- a/src/runtime/cgo/libcgo.h +++ b/src/runtime/cgo/libcgo.h @@ -6,6 +6,7 @@ #include #include +#undef nil #define nil ((void*)0) #define nelem(x) (sizeof(x)/sizeof((x)[0]))