Skip to content

Commit cc5385d

Browse files
committed
Add UNITY_OUTPUT_START/COMPLETE_HEADER_DECLARATION macros (closes #799).
`UNITY_OUTPUT_CHAR` and `UNITY_OUTPUT_FLUSH` already let users provide their own extern prototype via the matching `*_HEADER_DECLARATION` macro (unity_internals.h:333-335 and :349-351). `UNITY_OUTPUT_START` and `UNITY_OUTPUT_COMPLETE` did not — so users wanting to install init / deinit hooks (e.g. serial port open/close, RTT/JTAG bring-up) could override the macro but had no Unity-sanctioned way to declare the function prototype. Add the matching `_HEADER_DECLARATION` triad for both `START` and `COMPLETE`, mirroring the FLUSH pattern verbatim. Add the corresponding commented-out documentation lines to examples/unity_config.h so users discover the new option alongside the existing ones. Purely additive — the new code path only activates when the user defines both `UNITY_OUTPUT_START` (or `_COMPLETE`) AND the matching `*_HEADER_DECLARATION`. Default no-op behaviour is unchanged.
1 parent c7b0faa commit cc5385d

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

examples/unity_config.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@
228228
/* #define UNITY_OUTPUT_CHAR_HEADER_DECLARATION RS232_putc(int) */
229229
/* #define UNITY_OUTPUT_FLUSH() RS232_flush() */
230230
/* #define UNITY_OUTPUT_FLUSH_HEADER_DECLARATION RS232_flush(void) */
231-
/* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */
232-
/* #define UNITY_OUTPUT_COMPLETE() RS232_close() */
231+
/* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */
232+
/* #define UNITY_OUTPUT_START_HEADER_DECLARATION RS232_config(int,int,int,int) */
233+
/* #define UNITY_OUTPUT_COMPLETE() RS232_close() */
234+
/* #define UNITY_OUTPUT_COMPLETE_HEADER_DECLARATION RS232_close(void) */
233235

234236
/* Some compilers require a custom attribute to be assigned to pointers, like
235237
* `near` or `far`. In these cases, you can give Unity a safe default for these

src/unity_internals.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,20 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
363363

364364
#ifndef UNITY_OUTPUT_START
365365
#define UNITY_OUTPUT_START()
366+
#else
367+
/* If defined as something else, make sure we declare it here so it's ready for use */
368+
#ifdef UNITY_OUTPUT_START_HEADER_DECLARATION
369+
extern void UNITY_OUTPUT_START_HEADER_DECLARATION;
370+
#endif
366371
#endif
367372

368373
#ifndef UNITY_OUTPUT_COMPLETE
369374
#define UNITY_OUTPUT_COMPLETE()
375+
#else
376+
/* If defined as something else, make sure we declare it here so it's ready for use */
377+
#ifdef UNITY_OUTPUT_COMPLETE_HEADER_DECLARATION
378+
extern void UNITY_OUTPUT_COMPLETE_HEADER_DECLARATION;
379+
#endif
370380
#endif
371381

372382
#ifdef UNITY_INCLUDE_EXEC_TIME

0 commit comments

Comments
 (0)