tag:blogger.com,1999:blog-25777152.post114586476059195194..comments2015-12-10T02:48:17.537-08:00Comments on Code Rants: Tracing in linuxAnihttp://www.blogger.com/profile/09016215367013182386noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-25777152.post-1146210433569083572006-04-28T00:47:00.000-07:002006-04-28T00:47:00.000-07:00Reddy, just remembered this from CFAQ yesterday, a...Reddy, just remembered this from CFAQ yesterday, actually, you can do away with double-parens '((' which is confusing and we have to remember to type in each time.<BR/><BR/>Instead, you can write the macro in a different way so that you dont need double-parens:<BR/><BR/>Sample:<BR/><BR/>#define DEBUG printf("\n%s:%d - %s: ", __FILE__, __LINE__, __FUNCTION__), printf<BR/><BR/>you can call the macro like<BR/><BR/>DEBUG ("Hello \n");<BR/><BR/>--<BR/>AniAnihttps://www.blogger.com/profile/09016215367013182386noreply@blogger.comtag:blogger.com,1999:blog-25777152.post-1145879759438996002006-04-24T04:55:00.000-07:002006-04-24T04:55:00.000-07:00Definitely, you can use __FILE__ and __LINE__ as t...Definitely, you can use __FILE__ and __LINE__ as they are ANSI std.<BR/>But __FUNCTION__ is not! (still most compilers including gcc provide this as an extension)<BR/><BR/>What warnings could you not supress?<BR/><BR/>Generally, for logging functionalities, macros call external functions which can do various things, like log it to a local file, or transfer to a remote filesystems where logs are archived.<BR/><BR/>I dont see any efficiecy concerns here. Infact I've seen lots of such usage.Anihttps://www.blogger.com/profile/09016215367013182386noreply@blogger.comtag:blogger.com,1999:blog-25777152.post-1145867931174757272006-04-24T01:38:00.000-07:002006-04-24T01:38:00.000-07:00using va_list in functions, you can get variable n...using va_list in functions, you can get variable number of arguments (Since it is in stdarg.h - it's standard, hence portable)- fine.<BR/><BR/>But to call a macro with variable number of args, either you must use ISO C99 standard compliant compiler, which allows something like <BR/> #define debug(format, ...)<BR/><BR/>Or use the GCC extension - which still supports variadic macros, but with a slightly different syntax.<BR/> #define debug(format, args...)<BR/><BR/>--<BR/>AniAnihttps://www.blogger.com/profile/09016215367013182386noreply@blogger.com