Skip to content

Commit 1317b74

Browse files
authored
Merge pull request cpputest#1164 from SaeedYasin/fix_for_clang_macosx
Fix CppUTest for OSX / Xcode9 / clang-900.x or any newer version
2 parents 2edc6bb + 0f2cfce commit 1317b74

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

‎build/MakefileWorker.mk‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,12 @@ ifeq ($(COMPILER_NAME),$(CLANG_STR))
198198
CPPUTEST_CXX_WARNINGFLAGS += -Weverything -Wno-disabled-macro-expansion -Wno-padded -Wno-global-constructors -Wno-exit-time-destructors -Wno-weak-vtables -Wno-old-style-cast -Wno-c++11-long-long
199199
CPPUTEST_C_WARNINGFLAGS += -Weverything -Wno-padded
200200

201-
# Clang "7" (Xcode 7 command-line tools) introduced new warnings by default that don't exist on previous versions of clang and cause errors when present.
202-
ifeq ($(findstring clang-7,$(CC_VERSION_OUTPUT)),clang-7)
201+
# Clang "7" or newer (Xcode 7 or newer command-line tools) introduced new warnings by default that don't exist on previous versions of clang and cause errors when present.
202+
CLANG_VERSION := $(shell echo $(CC_VERSION_OUTPUT) | grep -o 'clang-[0-9][0-9][0-9]*.')
203+
CLANG_VERSION_NUM := $(subst .,,$(subst clang-,,$(CLANG_VERSION)))
204+
CLANG_VERSION_NUM_GT_700 := $(shell [[ $(CLANG_VERSION_NUM) -ge 700 ]] && echo Y)
205+
206+
ifeq ($(CLANG_VERSION_NUM_GT_700), Y)
203207
# -Wno-reserved-id-macro -> Many CppUTest macros start with __, which is a reserved namespace
204208
# -Wno-keyword-macro -> CppUTest redefines the 'new' keyword for memory leak tracking
205209
CPPUTEST_CXX_WARNINGFLAGS += -Wno-reserved-id-macro -Wno-keyword-macro

‎examples/AllTests/EventDispatcherTest.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ class EventComparator : public MockNamedValueComparator
4747
public:
4848
virtual bool isEqual(const void* object1, const void* object2)
4949
{
50-
return ((Event*)object1)->type == ((Event*)object2)->type;
50+
return ((const Event*)object1)->type == ((const Event*)object2)->type;
5151
}
5252
virtual SimpleString valueToString(const void* object)
5353
{
54-
return StringFrom(((Event*)object)->type);
54+
return StringFrom(((const Event*)object)->type);
5555
}
5656
};
5757

0 commit comments

Comments
 (0)