Hi,
I'm using Unity 2.5.2 with PlaformIO 6.1.9 (latest version). I'm with a LOLIN S3 board (ESP32-S3).
I want to use TEST_PRINTF(), so I set -D UNITY_INCLUDE_PRINT_FORMATTED in my compilation flags.
I got a compile time error:
PS C:\Users\pasca\src\spaiot-lib> pio test -f test_10_controlpanel -v
Collected 11 tests (test_01_blink, test_02_bussettings, test_03_ledsettings, test_04_buttonsettings, test_05_type_name, test_06_hardwaresettings, test_07_multiplexer, test_07_pcf8574mux, test_08_button, test_09_framedecoder, test_10_controlpanel)
Processing test_10_controlpanel in spaiot_shield_s3_4051_debug environment
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Building & Uploading...
In file included from test/spaiot_test.h:4,
from test/test_10_controlpanel/main.cpp:5:
test/test_10_controlpanel/main.cpp: In function 'void test_constructor()':
.pio/libdeps/spaiot_shield_s3_4051_debug/Unity/src/unity.h:108:144: error: expected primary-expression before ')' token
#define TEST_PRINTF(message, ...) UnityPrintF(__LINE__, (message), __VA_ARGS__)
^
test/test_10_controlpanel/main.cpp:43:3: note: in expansion of macro 'TEST_PRINTF'
TEST_PRINTF ("---> test_constructor <---\n");
^~~~~~~~~~~
test/test_10_controlpanel/main.cpp: In function 'void test_getters()':
.pio/libdeps/spaiot_shield_s3_4051_debug/Unity/src/unity.h:108:144: error: expected primary-expression before ')' token
#define TEST_PRINTF(message, ...) UnityPrintF(__LINE__, (message), __VA_ARGS__)
^
test/test_10_controlpanel/main.cpp:52:3: note: in expansion of macro 'TEST_PRINTF'
TEST_PRINTF ("---> test_getters <---\n");
^~~~~~~~~~~
The compiler reports an error after __VA_ARGS__.
The problem is that TEST_PRINTF() is defined as a variadic macro, but I'm not passing any variadic argument. Sure, i may use TEST_MESSAGE() instead, but if someone wants to use TEST_PRINTF() it should work.
Hi,
I'm using Unity 2.5.2 with PlaformIO 6.1.9 (latest version). I'm with a LOLIN S3 board (ESP32-S3). I want to use TEST_PRINTF(), so I set
-D UNITY_INCLUDE_PRINT_FORMATTED
in my compilation flags. I got a compile time error:The compiler reports an error after
__VA_ARGS__
. The problem is thatTEST_PRINTF()
is defined as a variadic macro, but I'm not passing any variadic argument. Sure, i may useTEST_MESSAGE()
instead, but if someone wants to useTEST_PRINTF()
it should work.I read this document: https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html and I modified the macro
TEST_PRINTF()
in the following way:So everything works:
I'm forked the original repository and I'm going to make a pull request to the original author to fix this problem.