From 7d0f8403abfb9c259f5f4b4da230f8d997d2c07a Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 31 May 2019 22:07:51 -0400 Subject: [PATCH] Fixed build errors on other platforms. This is a headache and a half :D I should split the files into strsafe_vsnprintf and strsafe_strncpy, but I want to share this file as is in one piece for now. --- common/uipriv.h | 2 ++ sharedbits/strsafe_impl.h | 2 ++ test/main.c | 1 + test/noinitwrongthread.c | 17 +++++++++++++---- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/common/uipriv.h b/common/uipriv.h index f395c5b7..3af07782 100644 --- a/common/uipriv.h +++ b/common/uipriv.h @@ -1,5 +1,7 @@ // 19 april 2019 +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/sharedbits/strsafe_impl.h b/sharedbits/strsafe_impl.h index 357e760a..1be64d9a 100644 --- a/sharedbits/strsafe_impl.h +++ b/sharedbits/strsafe_impl.h @@ -15,6 +15,7 @@ extern void sharedbitsprivInternalError(const char *fmt, ...); #endif +#ifndef sharedbitsNoVsnprintf #ifdef sharedbitsStatic sharedbitsStatic #endif @@ -35,6 +36,7 @@ int sharedbitsPrefixName(Vsnprintf)(char *s, size_t n, const char *fmt, va_list return vsnprintf(s, n, fmt, ap); #endif } +#endif #ifdef sharedbitsStatic sharedbitsStatic diff --git a/test/main.c b/test/main.c index 2ec2578a..063f00b0 100644 --- a/test/main.c +++ b/test/main.c @@ -64,5 +64,6 @@ int main(int argc, char *argv[]) return 1; } printf("PASS\n"); + fflush(stdout); // AddressSanitizer can chop the tail end of the output for whatever reason return 0; } diff --git a/test/noinitwrongthread.c b/test/noinitwrongthread.c index 129ef276..c1ae34e3 100644 --- a/test/noinitwrongthread.c +++ b/test/noinitwrongthread.c @@ -23,10 +23,8 @@ static char caseErrorEncodingError[] = "encoding error while handling other case #define sharedbitsPrefix priv #define sharedbitsStatic static -#include "../../sharedbits/strsafe_impl.h" -#undef sharedbitsStatic -#undef sharedbitsPrefix - +// do this conditionally to avoid warnings on non-Windows +#ifdef _WIN32 static void privInternalError(const char *fmt, ...) { va_list ap, ap2; @@ -50,6 +48,17 @@ static void privInternalError(const char *fmt, ...) privVsnprintf(caseError, n + 1, fmt, ap); va_end(ap); } +#else +#define sharedbitsInternalError +#define sharedbitsNoVsnprintf +#endif +#include "../../sharedbits/strsafe_impl.h" +#ifndef _WIN32 +#undef sharedbitsNoVsnprintf +#undef sharedbitsInternalError +#endif +#undef sharedbitsStatic +#undef sharedbitsPrefix static void catalogProgrammerError(const char *prefix, const char *msg, const char *suffix, bool internal) {