Skip to content

Commit a868b2e

Browse files
authored
Merge pull request ThrowTheSwitch#286 from palaviv/fix-UNITY_OUTPUT_FLUSH
Allow specifying custom header declaration (Thanks!)
2 parents c1bc32d + e56378e commit a868b2e

6 files changed

Lines changed: 17 additions & 13 deletions

File tree

examples/unity_config.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,12 @@
201201
* `stdout` option. You decide to route your test result output to a custom
202202
* serial `RS232_putc()` function you wrote like thus:
203203
*/
204-
/* #define UNITY_OUTPUT_CHAR(a) RS232_putc(a) */
205-
/* #define UNITY_OUTPUT_FLUSH() RS232_flush() */
206-
/* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */
207-
/* #define UNITY_OUTPUT_COMPLETE() RS232_close() */
204+
/* #define UNITY_OUTPUT_CHAR(a) RS232_putc(a) */
205+
/* #define UNITY_OUTPUT_CHAR_HEADER_DECLARATION RS232_putc(int) */
206+
/* #define UNITY_OUTPUT_FLUSH() RS232_flush() */
207+
/* #define UNITY_OUTPUT_FLUSH_HEADER_DECLARATION RS232_flush(void) */
208+
/* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */
209+
/* #define UNITY_OUTPUT_COMPLETE() RS232_close() */
208210

209211
/* For some targets, Unity can make the otherwise required `setUp()` and
210212
* `tearDown()` functions optional. This is a nice convenience for test writers

extras/fixture/rakefile_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def build_compiler_fields
5353
defines = if $cfg['compiler']['defines']['items'].nil?
5454
''
5555
else
56-
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'])
56+
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)'])
5757
end
5858
options = squash('', $cfg['compiler']['options'])
5959
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])

extras/fixture/test/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ endif
66
CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror
77
CFLAGS += $(DEBUG)
88
DEFINES = -D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar
9+
DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)
910
SRC = ../src/unity_fixture.c \
1011
../../../src/unity.c \
1112
unity_fixture_Test.c \

src/unity_internals.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,31 +246,31 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
246246
#define UNITY_OUTPUT_CHAR(a) (void)putchar(a)
247247
#else
248248
/* If defined as something else, make sure we declare it here so it's ready for use */
249-
#ifndef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION
250-
extern void UNITY_OUTPUT_CHAR(int);
249+
#ifdef UNITY_OUTPUT_CHAR_HEADER_DECLARATION
250+
extern void UNITY_OUTPUT_CHAR_HEADER_DECLARATION;
251251
#endif
252252
#endif
253253

254254
#ifndef UNITY_OUTPUT_FLUSH
255255
#ifdef UNITY_USE_FLUSH_STDOUT
256256
/* We want to use the stdout flush utility */
257257
#include <stdio.h>
258-
#define UNITY_OUTPUT_FLUSH (void)fflush(stdout)
258+
#define UNITY_OUTPUT_FLUSH() (void)fflush(stdout)
259259
#else
260260
/* We've specified nothing, therefore flush should just be ignored */
261-
#define UNITY_OUTPUT_FLUSH
261+
#define UNITY_OUTPUT_FLUSH()
262262
#endif
263263
#else
264264
/* We've defined flush as something else, so make sure we declare it here so it's ready for use */
265-
#ifndef UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION
266-
extern void UNITY_OUTPUT_FLUSH(void);
265+
#ifdef UNITY_OUTPUT_FLUSH_HEADER_DECLARATION
266+
extern void UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION;
267267
#endif
268268
#endif
269269

270270
#ifndef UNITY_OUTPUT_FLUSH
271271
#define UNITY_FLUSH_CALL()
272272
#else
273-
#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH
273+
#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH()
274274
#endif
275275

276276
#ifndef UNITY_PRINT_EOL

test/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstri
1414
#DEBUG = -O0 -g
1515
CFLAGS += $(DEBUG)
1616
DEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy
17+
DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\)
1718
DEFINES += -D UNITY_SUPPORT_64 -D UNITY_INCLUDE_DOUBLE
1819
SRC = ../src/unity.c tests/testunity.c build/testunityRunner.c
1920
INC_DIR = -I ../src

test/rakefile_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def build_compiler_fields(inject_defines)
9191
defines = if $cfg['compiler']['defines']['items'].nil?
9292
''
9393
else
94-
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=putcharSpy'] + inject_defines)
94+
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=putcharSpy'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\)'] + inject_defines)
9595
end
9696
options = squash('', $cfg['compiler']['options'])
9797
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])

0 commit comments

Comments
 (0)