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.
This commit is contained in:
Andy Isaacson
2015-10-28 18:02:45 -07:00
parent 0c9fc9bb33
commit d4b83f180b

View File

@ -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);