Re: macro taking variable args by tsindia
tsindia
Thu Apr 06 00:44:03 CDT 2006
Hi David,
Yes, I had defined an inline function to use va_list which was working
fine. The problem is that I am trying to print the file name and the line
number of the debug message, but it prints the file name and teh line number
of the debug function and not where the debug message is actually occcuring.
That's why i was trying to use a macro instead of a function using va_list.
Sorry to bother you if my question is stupid. The inline function I am
talking of is defined as below:
__inline void AMZ_OSAL_debug1(char *msg_fmt, ...)
{
char msg_buffer[MSG_LEN];
va_list arg_list;
KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_TRACE_LEVEL,
"DEBUG LOG %s, line-%d%::", __FILE__, __LINE__ ));
va_start( arg_list, msg_fmt );
RtlStringCbVPrintfA(msg_buffer, MSG_LEN, msg_fmt,arg_list);
va_end(arg_list);
KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_TRACE_LEVEL,
"%s\n", msg_buffer));
return;
}
I hope you will realise that this won't print the file name and the line
number that i wish it to print.
Regds.
"David J. Craig" <Dave@yoshimuni.com> wrote in message
news:%23rJLwlTWGHA.4768@TK2MSFTNGP05.phx.gbl...
> Microsoft uses va_list.
>
> Try looking in the headers as this is too simple and so much faster than
> trying to learn via email or newsgroups.
>
> "tsindia" <tsindia@newsgroups.nospam> wrote in message
> news:Oc$qUdTWGHA.1348@TK2MSFTNGP05.phx.gbl...
>> Hi ,
>>
>> ISO C defines macros that can take variable arguments. The code below
>> compiles on linux but fails with DDK XP. Do I have a similar option in
>> windows.
>>
>> #define AMZ_OSAL_debug1(format, ...) \
>>
>> {\
>>
>> KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_TRACE_LEVEL, \
>>
>> "DEBUG LOG %s, line-%d%::", __FILE__, __LINE__ ));\
>>
>> KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_TRACE_LEVEL,\
>>
>> format, __VA_ARGS__ ));\
>>
>> KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_TRACE_LEVEL,\
>>
>> "/n"));\
>>
>> }
>>
>>
>>
>>
>>
>> Thanks.
>>
>> Nitin
>>
>>
>
>