From a07d07cd1a2726b6d798f5b0bb3d9123dd63ab59 Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Tue, 1 Aug 2017 21:49:38 +0300 Subject: [PATCH] Allow specifying custom header declaration The user can specify UNITY_OUTPUT_CHAR_HEADER_DECLARATION and UNITY_OUTPUT_FLUSH_HEADER_DECLARATION when he would like to declare UNITY_OUTPUT_CHAT or UNITY_OUTPUT_FLUSH respectivly --- examples/unity_config.h | 10 ++++++---- src/unity_internals.h | 14 +++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/examples/unity_config.h b/examples/unity_config.h index 355d9bf..da3c2af 100644 --- a/examples/unity_config.h +++ b/examples/unity_config.h @@ -201,10 +201,12 @@ * `stdout` option. You decide to route your test result output to a custom * serial `RS232_putc()` function you wrote like thus: */ -/* #define UNITY_OUTPUT_CHAR(a) RS232_putc(a) */ -/* #define UNITY_OUTPUT_FLUSH() RS232_flush() */ -/* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */ -/* #define UNITY_OUTPUT_COMPLETE() RS232_close() */ +/* #define UNITY_OUTPUT_CHAR(a) RS232_putc(a) */ +/* #define UNITY_OUTPUT_CHAR_HEADER_DECLARATION RS232_putc(int) */ +/* #define UNITY_OUTPUT_FLUSH() RS232_flush() */ +/* #define UNITY_OUTPUT_FLUSH_HEADER_DECLARATION RS232_flush(void) */ +/* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */ +/* #define UNITY_OUTPUT_COMPLETE() RS232_close() */ /* For some targets, Unity can make the otherwise required `setUp()` and * `tearDown()` functions optional. This is a nice convenience for test writers diff --git a/src/unity_internals.h b/src/unity_internals.h index c08db95..9504451 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -246,8 +246,8 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT; #define UNITY_OUTPUT_CHAR(a) (void)putchar(a) #else /* If defined as something else, make sure we declare it here so it's ready for use */ - #ifndef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION -extern void UNITY_OUTPUT_CHAR(int); + #ifdef UNITY_OUTPUT_CHAR_HEADER_DECLARATION +extern void UNITY_OUTPUT_CHAR_HEADER_DECLARATION; #endif #endif @@ -255,22 +255,22 @@ extern void UNITY_OUTPUT_CHAR(int); #ifdef UNITY_USE_FLUSH_STDOUT /* We want to use the stdout flush utility */ #include -#define UNITY_OUTPUT_FLUSH (void)fflush(stdout) +#define UNITY_OUTPUT_FLUSH() (void)fflush(stdout) #else /* We've specified nothing, therefore flush should just be ignored */ -#define UNITY_OUTPUT_FLUSH +#define UNITY_OUTPUT_FLUSH() #endif #else /* We've defined flush as something else, so make sure we declare it here so it's ready for use */ -#ifndef UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION -extern void UNITY_OUTPUT_FLUSH(void); +#ifdef UNITY_OUTPUT_FLUSH_HEADER_DECLARATION +extern void UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION; #endif #endif #ifndef UNITY_OUTPUT_FLUSH #define UNITY_FLUSH_CALL() #else -#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH +#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH() #endif #ifndef UNITY_PRINT_EOL -- GitLab