From bc8533836b75a8c9f586f433bcc739574454d8b3 Mon Sep 17 00:00:00 2001 From: Andy Isaacson Date: Tue, 27 Oct 2015 17:24:55 -0700 Subject: [PATCH 1/3] add C++ guards in unity.h --- src/unity.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/unity.h b/src/unity.h index da22820..18470b4 100644 --- a/src/unity.h +++ b/src/unity.h @@ -8,6 +8,11 @@ #define UNITY_FRAMEWORK_H #define UNITY +#ifdef __cplusplus +extern "C" +{ +#endif + #include "unity_internals.h" //------------------------------------------------------- @@ -271,4 +276,7 @@ #define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, (message)) //end of UNITY_FRAMEWORK_H +#ifdef __cplusplus +} +#endif #endif From 0c9fc9bb334825ee3d99ce902e21a36a7f5e4811 Mon Sep 17 00:00:00 2001 From: Andy Isaacson Date: Tue, 27 Oct 2015 18:18:52 -0700 Subject: [PATCH 2/3] add prototypes for setUp and tearDown to unity.h --- src/unity.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/unity.h b/src/unity.h index 18470b4..342cb22 100644 --- a/src/unity.h +++ b/src/unity.h @@ -15,6 +15,9 @@ extern "C" #include "unity_internals.h" +void setUp(void); +void tearDown(void); + //------------------------------------------------------- // Configuration Options //------------------------------------------------------- From d4b83f180b0592c8159272ed9d666d06d1a7c046 Mon Sep 17 00:00:00 2001 From: Andy Isaacson Date: Wed, 28 Oct 2015 18:02:45 -0700 Subject: [PATCH 3/3] 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);