From 23b26820f54d6127bf09e83133a49d254a3a851d Mon Sep 17 00:00:00 2001 From: theraven Date: Wed, 6 Apr 2011 18:17:18 +0000 Subject: [PATCH] Make it easier to suppress mismatched selector warnings. It's useful for the runtime to tell you when your code is bad. Not so useful for it to tell you when someone else's code is bad... --- GNUmakefile | 12 ++++++++---- Makefile | 3 +++ sendmsg2.c | 8 ++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 7aa7622..9db86f6 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -67,6 +67,7 @@ libobjc_HEADER_FILES = \ toydispatch.h endif +# Disable type dependent dispatch if tdd=no is specified ifneq ($(tdd), no) libobjc_CPPFLAGS += -DTYPE_DEPENDENT_DISPATCH endif @@ -77,6 +78,12 @@ else libobjc_LIBRARIES_DEPEND_UPON += -lpthread endif +# If we're doing a release build, don't tell people that the code that they're +# using is rubbish - they complain. +#CPPFLAGS += -DNO_SELECTOR_MISMATCH_WARNINGS + +libobjc_CFLAGS += -O3 + # Deprecated functions are only deprecated for external use, not for us because # we are special, precious, little flowers. libobjc_CPPFLAGS += -D__OBJC_RUNTIME_INTERNAL__=1 -D_XOPEN_SOURCE=500 @@ -84,16 +91,13 @@ libobjc_CPPFLAGS += -D__OBJC_RUNTIME_INTERNAL__=1 -D_XOPEN_SOURCE=500 # useful on compilers that support C99 (currently only clang), so there is no # benefit from supporting platforms with no C99 compiler. libobjc_CFLAGS += -std=gnu99 -g -fexceptions #-fvisibility=hidden -libobjc_CFLAGS += -Wno-unused-function libobjc_CCFLAGS += -std=c++98 -g -fexceptions #-fvisibility=hidden +libobjc_CFLAGS += -Wno-unused-function # Uncomment this when debugging - it makes everything slow, but means that the # debugger actually works... #libobjc_CFLAGS += -fno-inline libobjc_OBJCFLAGS += $(libobjc_CFLAGS) $(libobjc_CFLAGS) -libobjc_LDFLAGS += -g - -libobjc_CFLAGS += -O3 ifneq ($(findstring gcc, $(CC)),) # Hack to get the __sync_* GCC builtins to work with GCC diff --git a/Makefile b/Makefile index e77d5ce..f59fd81 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,9 @@ CXXFLAGS += -fPIC CPPFLAGS += -DTYPE_DEPENDENT_DISPATCH -DGNUSTEP CPPFLAGS += -D__OBJC_RUNTIME_INTERNAL__=1 -D_XOPEN_SOURCE=500 +# Suppress warnings about incorrect selectors +CPPFLAGS += -DNO_SELECTOR_MISMATCH_WARNINGS + PREFIX?= /usr/local LIB_DIR= ${PREFIX}/lib HEADER_DIR= ${PREFIX}/include diff --git a/sendmsg2.c b/sendmsg2.c index 57ed754..51f98cb 100644 --- a/sendmsg2.c +++ b/sendmsg2.c @@ -25,6 +25,7 @@ static Slot_t objc_msg_forward3_null(id receiver, SEL op) { return &nil_slot; } id (*objc_proxy_lookup)(id receiver, SEL op) = objc_proxy_lookup_null; Slot_t (*__objc_msg_forward3)(id receiver, SEL op) = objc_msg_forward3_null; +#ifdef NO_SELECTOR_MISMATCH_WARNINGS static struct objc_slot* objc_selector_type_mismatch(Class cls, SEL selector, Slot_t result) { @@ -37,6 +38,13 @@ static struct objc_slot* objc_selector_type_mismatch(Class cls, SEL sel_getType_np(selector)); return result; } +#else +static struct objc_slot* objc_selector_type_mismatch(Class cls, SEL + selector, Slot_t result) +{ + return result; +} +#endif struct objc_slot* (*_objc_selector_type_mismatch)(Class cls, SEL selector, struct objc_slot *result) = objc_selector_type_mismatch; static