From 39cc60ce567a25bf00d30c7a080f5d758c8d4180 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Tue, 8 Jul 2014 12:14:26 -0400 Subject: [PATCH] - support "weak" function definitions when available with compiler. --- src/unity.c | 6 ++++++ src/unity_internals.h | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/unity.c b/src/unity.c index 29b40c2..919dafa 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1092,8 +1092,14 @@ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line) } //----------------------------------------------- +#ifdef UNITY_SUPPORT_WEAK +void setUp(void) { } +void tearDown(void) { } +#else void setUp(void); void tearDown(void); +#endif +//----------------------------------------------- void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum) { Unity.CurrentTestName = FuncName; diff --git a/src/unity_internals.h b/src/unity_internals.h index d80c72d..18a8777 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -260,6 +260,26 @@ extern int UNITY_OUTPUT_CHAR(int); #define UNITY_COUNTER_TYPE _U_UINT #endif +//------------------------------------------------------- +// Language Features Available +//------------------------------------------------------- + +#ifdef __GNUC__ +#define UNITY_SUPPORT_WEAK __attribute__((weak)) +#endif + +#ifdef __clang__ +#define UNITY_SUPPORT_WEAK __attribute__((weak)) +#endif + +#ifndef UNITY_WEAK +#ifdef UNITY_SUPPORT_WEAK +#define UNITY_WEAK __attribute__((weak)) +#else +#define UNITY_WEAK +#endif +#endif + //------------------------------------------------------- // Internal Structs Needed //-------------------------------------------------------