第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

有一個(gè)記錄日志的函數(shù),想用宏定義進(jìn)行包裝,簡(jiǎn)化調(diào)用方法,但是xlc報(bào)如下的錯(cuò)誤:

有一個(gè)記錄日志的函數(shù),想用宏定義進(jìn)行包裝,簡(jiǎn)化調(diào)用方法,但是xlc報(bào)如下的錯(cuò)誤:

C
一只名叫tom的貓 2023-04-25 20:16:37
void _log(const int level, char* file, int line, const char* fmt, ...){ va_list ap; int count; time_t t; struct tm* st; char str_time[255]; memset(str_time, 0x00, sizeof(str_time)); time(&t); st= localtime(&t); switch(level){ case DEBUG: fprintf(stdout, "[DEBUG] "); break; case INFO: fprintf(stdout, "[INFO] "); break; case WARNING: fprintf(stdout, "[WARNING] "); break; case ERROR: fprintf(stdout, "[ERROR] "); break; default: fprintf(stdout, "[INFO] "); break; } strftime( str_time, sizeof(str_time), "%Y-%m-%d %H:%M:%S", st); fprintf(stdout, "[%s] LINE:[%04d] [%s] ", file, line, str_time); va_start(ap, fmt); count = vfprintf(stdout, fmt, ap); fprintf(stdout, "\n"); fflush(stdout); va_end(ap); }#define log_info(...) _log((INFO), (__FILE__), (__LINE__), "", (#__VA_ARGS__))#define log_err(...) _log((ERROR), (__FILE__), (__LINE__), "", (#__VA_ARGS__))Syntax error at line 71, column 18, file RProCrminfo.cp:Error at line 71, column 18 in file RProCrminfo.cpdefine log_info((aaa), ...) _log((INFO), (__FILE__), (__LINE__), "", (#__VA_ARGS__)).................1PCC-S-02014, Encountered the symbol "(" when expecting one of the following:) ... an identifier, define, elif, else, endif, error, if,ifdef, ifndef, include, line, pragma, undef, exec, sql,begin, end, var, type, oracle,an immediate preprocessor command, a C token, create,function, package, procedure, trigger, or, replace,The symbol ")" was substituted for "(" to continue.
查看完整描述

1 回答

?
婷婷同學(xué)_

TA貢獻(xiàn)1844條經(jīng)驗(yàn) 獲得超8個(gè)贊

早先一個(gè)項(xiàng)目woj-land里用到的,供參考

#define FM_LOG_DEBUG(x...)   log_write(LOG_DEBUG, __FILE__, __LINE__, ##x)static void log_write(int level, const char *file,        const int line, const char *fmt, ...){    if (log_opened == 0)
    {        fprintf(stderr, "log_open not called yet\n");        exit(1);
    }    static char buffer[log_buffer_size];    static char datetime[100];    static char line_str[20];    static time_t now;
    now = time(NULL);    strftime(datetime, 99, "%Y-%m-%d %H:%M:%S", localtime(&now));    snprintf(line_str, 19, "%d", line);
    va_list ap;    va_start(ap, fmt);   
    vsnprintf(log_buffer, log_buffer_size, fmt, ap);   
    va_end(ap);   

    size_t count = snprintf(buffer, log_buffer_size,            "%s\x7 [%s]\x7 [%s:%d]%s\x7 %s\x7\n", 
            LOG_LEVEL_NOTE[level], datetime, file, line, log_extra_info, log_buffer);    int log_fd = log_fp->_fileno;    //puts(buffer);
    if (flock(log_fd, LOCK_EX) == 0)
    {        if (write(log_fd, buffer, count) < 0)
        {            perror("write error");            exit(1);
        }        flock(log_fd, LOCK_UN);
    }    else
    {        perror("flock error");        exit(1);
    }
}
查看完整回答
反對(duì) 回復(fù) 2023-04-28
  • 1 回答
  • 0 關(guān)注
  • 244 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)