Original Post
Hi, I'm trying to create a simple Logging system, and the compiler doesn't seem to like va_start... Here's my source code, am I missing something stupid? When I try to compile, I get ('va_start': identifier not found, even with argument-dependent lookup). Is there something else I need to include? It seems to be finding va_list alright, I would have figured it would find va_start if it found va_list.... Thanks for any help!
#include "Singleton.h"
#include <stdio.h>
#include <stdlib.h>
#include <string>
class Log: public Singleton<Log>
{
public:
Log(): EngineLog(NULL), AppLog(NULL){}
~Log(){}
void Init()
{
EngineLog = fopen("LOG/EngineLog.txt", "w");
AppLog = fopen("LOG/AppLog.txt", "w");
if (!EngineLog)
printf("EngineLog not Opened! \n");
if (!AppLog)
printf("AppLog not Opened! \n");
}
void Shutdown()
{
if (EngineLog)
fclose(EngineLog);
if (AppLog)
fclose(AppLog);
}
//Do a cheat to support the same interface as Printf
//Note, this isn't safe from buffer overflows. Don't try
// to print arbitrary length strings in here.
void WriteEngine(const char *msg, ...)
{
va_list args;
va_start(args,msg);
char szBuf[1024];
vsprintf(szBuf,msg,args);
fprintf(EngineLog, "%s", szBuf);
}
//Same as above
void WriteApp(const char *msg, ...)
{
va_list args;
va_start(args,msg);
char szBuf[1024];
vsprintf(szBuf,msg,args);
fprintf(AppLog, "%s", szBuf);
}
private:
FILE *EngineLog;
FILE *AppLog;
};