HI I (re)use this piece of code for OS4 and OS3 and with VBCC, OS3 build works fine, but OS4 build I get always a crash :-(
What am I doing wrong? Do I need to use/add "VA_ARG(ap,
Alresdy read "https://os4coding.net/forum/vsprintf" but still don't get it.
void VARARGS68K log_printf(struct ArchiverData *ad, int type, const char *fmt, ...) { static char log_buf[16], buffer[2048]; struct DateStamp ds; int hour, minute, second, offset; VA_LIST ap; struct ArchiverGUI *ag = &ad->ad_GUIData; assert(type >= LOG_INFO && type <= LOG_ERROR); DateStamp(&ds); ObtainSemaphore(&ad->ad_LogSem); hour = ds.ds_Minute / 60; minute = ds.ds_Minute % 60; second = ds.ds_Tick / TICKS_PER_SECOND; offset = SNPrintf(log_buf, sizeof(log_buf), "%lc: [%02ld:%02ld:%02ld] ", log_type[type], hour, minute, second); Write(ad->ad_LogFile, log_buf, strlen(log_buf)); VA_START(ap, fmt); VSNPrintf(buffer, sizeof(buffer), fmt, ap); //VSNPrintf(buffer + offset, sizeof(buffer) - offset, fmt,ap); VA_END(ap); #ifdef _USE_MUI_ if(ag->ag_Status) { SetAttrs(ag->ag_Status, MUIA_Text_Contents,buffer, TAG_END); } #endif Strlcat(buffer, "\n", sizeof(buffer)); Write(ad->ad_LogFile, buffer, strlen(buffer)); ReleaseSemaphore(&ad->ad_LogSem); }
TiA