1
0
mirror of https://github.com/golang/go synced 2024-11-17 02:34:46 -07:00

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 <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Elias Naur 2018-03-07 18:23:21 +01:00
parent 709da95513
commit 7a2a96d6ad
3 changed files with 7 additions and 6 deletions

View File

@ -9,12 +9,12 @@
#include <sys/param.h> #include <sys/param.h>
#include <unistd.h> #include <unistd.h>
#include "libcgo.h"
#include "libcgo_unix.h"
#include <CoreFoundation/CFBundle.h> #include <CoreFoundation/CFBundle.h>
#include <CoreFoundation/CFString.h> #include <CoreFoundation/CFString.h>
#include "libcgo.h"
#include "libcgo_unix.h"
#define magic (0xe696c4f4U) #define magic (0xe696c4f4U)
// inittls allocates a thread-local storage slot for g. // inittls allocates a thread-local storage slot for g.

View File

@ -10,12 +10,12 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include "libcgo.h"
#include "libcgo_unix.h"
#include <CoreFoundation/CFBundle.h> #include <CoreFoundation/CFBundle.h>
#include <CoreFoundation/CFString.h> #include <CoreFoundation/CFString.h>
#include "libcgo.h"
#include "libcgo_unix.h"
#define magic (0xc476c475c47957UL) #define magic (0xc476c475c47957UL)
// inittls allocates a thread-local storage slot for g. // inittls allocates a thread-local storage slot for g.

View File

@ -6,6 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#undef nil
#define nil ((void*)0) #define nil ((void*)0)
#define nelem(x) (sizeof(x)/sizeof((x)[0])) #define nelem(x) (sizeof(x)/sizeof((x)[0]))