From e1e28f98f961cd6e2cfe7b5773e7d47ae65758e3 Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Sat, 9 Oct 2021 08:34:17 +0100 Subject: [PATCH] terminal: wrap UNITTEST block with #if guard to avoid linker errors See also: https://libera.irclog.whitequark.org/foot/2021-10-09 --- terminal.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/terminal.c b/terminal.c index 0f5b4b62..692d087f 100644 --- a/terminal.c +++ b/terminal.c @@ -2259,6 +2259,14 @@ term_erase_scrollback(struct terminal *term) term_damage_view(term); } +/* + * This UNITTEST block uses functions that don't have PGO stubs; so it could + * cause linker errors in PGO builds if the whole block isn't discarded by + * the compiler (e.g. when no optimization flags are used). Doing a PGO build + * without optimization usually makes very little sense, but we prevent such + * errors from happening anyway, by using an #if guard. + */ +#if defined(_DEBUG) UNITTEST { const int scrollback_rows = 16; @@ -2385,6 +2393,7 @@ UNITTEST free(term.normal.rows); fdm_destroy(fdm); } +#endif int term_row_rel_to_abs(const struct terminal *term, int row)