Print this C language where the function name, file name, line number

printf("[%s %s] %s: %s: %d\n", \
            __DATE__, __TIME__, __FILE__, __func__, __LINE__);

Kernel-mode driver:

#ifdef MY_DEBUG
    printf("[%s %s] %s: %s: %d\n", \
            __DATE__, __TIME__, __FILE__, __FUNCTION__, __LINE__);
#endif

Description:

Macros Features
__FILE__ File name of the current string
__FUNCTION__ or __func__ Current string function name
__LINE__ The current line number is an integer
__DATE__ String current date
__TIME__ String current time

Guess you like

Origin www.cnblogs.com/raina/p/11585665.html