fix Mac OSX build

This commit is contained in:
Erwin Coumans
2013-06-04 09:09:10 -07:00
parent b36eba864f
commit 4dd529513f
6 changed files with 95 additions and 67 deletions

View File

@@ -3,19 +3,20 @@
#include <stdio.h>
#include <stdarg.h>
void b3PrintfFuncDefault(const char* msg)
{
printf(msg);
printf("%s",msg);
}
void b3WarningMessageFuncDefault(const char* msg)
{
printf(msg);
printf("%s",msg);
}
void b3ErrorMessageFuncDefault(const char* msg)
{
printf(msg);
printf("%s",msg);
}
static b3PrintfFunc* b3s_printfFunc = b3PrintfFuncDefault;
@@ -37,13 +38,19 @@ void b3SetCustomErrorMessageFunc(b3PrintfFunc* errorMessageFunc)
b3s_errorMessageFunc = errorMessageFunc;
}
#define B3_MAX_DEBUG_STRING_LENGTH 32
void b3OutputPrintfVarArgsInternal(const char *str, ...)
{
char strDebug[1024]={0};
char strDebug[B3_MAX_DEBUG_STRING_LENGTH]={0};
va_list argList;
va_start(argList, str);
vsprintf_s(strDebug,str,argList);
#ifdef _WIN32
vsprintf_s(strDebug,B3_MAX_DEBUG_STRING_LENGTH,str,argList);
#else
vsnprintf(strDebug,B3_MAX_DEBUG_STRING_LENGTH,str,argList);
#endif
(b3s_printfFunc)(strDebug);
va_end(argList);
}
@@ -52,18 +59,30 @@ void b3OutputWarningMessageVarArgsInternal(const char *str, ...)
char strDebug[1024]={0};
va_list argList;
va_start(argList, str);
vsprintf_s(strDebug,str,argList);
#ifdef _WIN32
vsprintf_s(strDebug,B3_MAX_DEBUG_STRING_LENGTH,str,argList);
#else
vsnprintf(strDebug,B3_MAX_DEBUG_STRING_LENGTH,str,argList);
#endif
(b3s_warningMessageFunc)(strDebug);
va_end(argList);
}
void b3OutputErrorMessageVarArgsInternal(const char *str, ...)
{
char strDebug[1024]={0};
va_list argList;
va_start(argList, str);
vsprintf_s(strDebug,str,argList);
#ifdef _WIN32
vsprintf_s(strDebug,B3_MAX_DEBUG_STRING_LENGTH,str,argList);
#else
vsnprintf(strDebug,B3_MAX_DEBUG_STRING_LENGTH,str,argList);
#endif
(b3s_errorMessageFunc)(strDebug);
va_end(argList);
}
#ifndef _WIN32
#undef vsprintf_s
#endif