From d4b83f180b0592c8159272ed9d666d06d1a7c046 Mon Sep 17 00:00:00 2001 From: Andy Isaacson Date: Wed, 28 Oct 2015 18:02:45 -0700 Subject: [PATCH] define setUp and tearDown under UNITY_WEAK_PRAGMA The intent of UNITY_WEAK_PRAGMA is that we have weak symbols for setUp and tearDown in unity.o, so that developers can override these symbols if needed but the link works right if they are not defined. In order to do this using #pragma, the pragma and the definition of the function (not the declaration) need to be present in the same translation unit (source code file). Previously, the UNITY_WEAK_PRAGMA code was just declaring the setUp function, but not defining it, which means that developers had to add an empty setUp function to their tests in order to link. --- src/unity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unity.c b/src/unity.c index 244de46..dc2af66 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1231,9 +1231,9 @@ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line) UNITY_WEAK_ATTRIBUTE void tearDown(void) { } #elif defined(UNITY_WEAK_PRAGMA) # pragma weak setUp - void setUp(void); + void setUp(void) { } # pragma weak tearDown - void tearDown(void); + void tearDown(void) { } #else void setUp(void); void tearDown(void);