I have converted my old code:
#define MAX_LOG_MSG 2048
in the *.h file
typedef void (*LogMessageFunction)(char *);
in the *.cpp file
static LogMessageFunction m_MessageFunctions[LastLogCount] = {NULL};
void DebugMsg(const char* fmt, ...)
{
if (!m_MessageFunctions[DebugLevel]) return;
char msgBuffer[MAX_LOG_MSG];
va_list argList;
va_start(argList, fmt);
vsnprintf(msgBuffer, MAX_LOG_MSG, fmt, argList);
va_end(argList);
m_MessageFunctions[DebugLevel](msgBuffer);
}
into a dynamic allocated char*
void DebugMsg(const char* fmt, ...)
{
if (!m_MessageFunctions[DebugLevel]) return;
va_list argList;
va_start(argList, fmt);
size_t size = vsnprintf(NULL, 0, fmt, argList) + 1;
va_end(argList);
char* msgBuffer = new char[size];
va_start(argList, fmt);
vsnprintf(msgBuffer, size, fmt, argList);
va_end(argList);
m_MessageFunctions[DebugLevel](msgBuffer);
delete[] msgBuffer;
}
on windows everything works great now.
Thread 1 "ATETests" received signal SIGSEGV, Segmentation fault. __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65 65 ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.
as far as I can see this has something to do with the size of the buffer or the string? Can you help?