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.

This commit is contained in:
Pietro Gagliardi 2019-05-31 22:07:51 -04:00
parent a17b7c8c14
commit 7d0f8403ab
4 changed files with 18 additions and 4 deletions

View File

@ -1,5 +1,7 @@
// 19 april 2019
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -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

View File

@ -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;
}

View File

@ -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)
{