From 5b2888e1135311b9a5abc1334af2a26dc2d2c87e Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 5 Jan 2017 00:37:56 +0800 Subject: [PATCH] unity: fix testcase initializer for compiling with C++ --- .../components/unity/include/unity_config.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/unit-test-app/components/unity/include/unity_config.h b/tools/unit-test-app/components/unity/include/unity_config.h index b8e56a79c..07df5b305 100644 --- a/tools/unit-test-app/components/unity/include/unity_config.h +++ b/tools/unit-test-app/components/unity/include/unity_config.h @@ -61,11 +61,20 @@ void unity_run_all_tests(); .desc = desc_, \ .fn = &UNITY_TEST_UID(test_func_), \ .file = __FILE__, \ - .line = __LINE__ \ + .line = __LINE__, \ + .next = NULL \ }; \ unity_testcase_register( & UNITY_TEST_UID(test_desc_) ); \ }\ static void UNITY_TEST_UID(test_func_) (void) +/** + * Note: initialization of test_desc_t fields above has to be done exactly + * in the same order as the fields are declared in the structure. + * Otherwise the initializer will not be valid in C++ (which doesn't + * support designated initializers). G++ can parse the syntax, but + * field names are treated as annotations and don't affect initialization + * order. Also make sure all the fields are initialized. + */ // shorthand to check esp_err_t return code #define TEST_ESP_OK(rc) TEST_ASSERT_EQUAL_INT32(ESP_OK, rc)