mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-25 10:13:12 +08:00
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:
@ -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);
|
||||
|
Reference in New Issue
Block a user