hi i am developing new logger for android. in vc version i used log like this,
//ref http://stackoverflow.com/questions/8487986/file-macro-shows-full-path
#define CURRENT_FILE_NAME (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
//ref ##VAR things - http://www.delorie.com/gnu/docs/gcc/gcc_44.html
//ref define "" __vars__ something - http://mail-archives.apache.org/mod_mbox/httpd-dev/199710.mbox/%3CPine.LNX.3.95.971028083446.14671A-100000@gaia.vr.net%3E
#define printfAdv(fmt,...)\
{\
printf("[%s] " fmt " ... @(%s)[%s:%d]\n",__TIME__,##__VA_ARGS__,__FUNCTION__,CURRENT_FILE_NAME,__LINE__);\
fflush(stdout);\
}
#define LOGV(fmt,...) \
{\
printfAdv(fmt,__VA_ARGS__);\
}
->[09:59:42] inputting ... @(processInputKey)[vc_input.cpp:63] and it worked like charm.
but in android, it cannot be built since some error.
#define InternalLoggerv(...) __android_log_print(ANDROID_LOG_VERBOSE,LOG_TAG,__VA_ARGS__)
//ref http://stackoverflow.com/questions/8487986/file-macro-shows-full-path
//win for two back slash
#define CURRENT_FILE_NAME (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
//ref ##VAR things - http://www.delorie.com/gnu/docs/gcc/gcc_44.html
//ref define "" __vars__ something - http://mail-archives.apache.org/mod_mbox/httpd-dev/199710.mbox/%3CPine.LNX.3.95.971028083446.14671A-100000@gaia.vr.net%3E
#define printfAdv(fmt,...)\
{\
InternalLoggerv("" fmt " ... @(%s)[%s:%d]\n",##__VA_ARGS__,__FUNCTION__,CURRENT_FILE_NAME,__LINE__);\
}
// fflush(stdout);\
//printf(fmt " ... @(%s)[%s:%d]\n",##__VA_ARGS__,__FUNCTION__,CURRENT_FILE_NAME,__LINE__);\
//printf("[%s] " fmt " ... @(%s)[%s:%d]\n",__TIME__,##__VA_ARGS__,__FUNCTION__,CURRENT_FILE_NAME,__LINE__);\
#define LOGV(fmt,...) \
{\
printfAdv(fmt,__VA_ARGS__);\
}
This gives error when LOGV("blah blah"); not when LOGV("%s","blah balhh"); and error says 'expected primary-expression before ',' token'....
what makes this differnt, and how can i use sometihng like in android native deveolopemnt? thatnk you.