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

Re: macro taking variable args by David

David
Thu Apr 06 00:17:43 CDT 2006

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
>
>



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
>>
>>
>
>



Re: macro taking variable args by Mark

Mark
Thu Apr 06 06:33:31 CDT 2006

tsindia wrote:
> 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.
msoft C does not support vararg macros. You can simulate varargs by
wrapping the arguments in parenthesis on invocation.

> 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
>>>
>>>
>>
>>
>
>

RE: macro taking variable args by pavel_a

pavel_a
Thu Apr 06 17:55:02 CDT 2006

Ntoskrnl exports two vararg versions of DebugPrint:
vDbfPrintEx and vDbgPrintExWithPrefix.
They will do what you want.
But... these are not documented. The prototypes however are in wdm.h.

Regards,
--PA


"tsindia" wrote:
> 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
>


Re: macro taking variable args by Doron

Doron
Fri Apr 07 00:46:38 CDT 2006

variadic macros is a C99 spec feature which was only recently approved in
the last couple of years. The XP DDK was released before the spec was
complete.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"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
>
>



Re: macro taking variable args by Tim

Tim
Fri Apr 07 01:15:05 CDT 2006

Mark Roddy <markr@hollistech.com> wrote:

>tsindia wrote:
>> 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.
>
>msoft C does not support vararg macros. You can simulate varargs by
>wrapping the arguments in parenthesis on invocation.

Actually, much to my surprise, VC++ 8.0 does, exactly as he describes.
Howver, the 3790.1830 DDK includes VC++ 7.1, which does not.

The current WDK includes VC++ 8.0, so the __VA_ARGS__ thing will work.
Unfortunately, it's only in beta.

>>>> 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"));\
>>>>}

That exact code works in VC++ 8.0. The OP is just a bit ahead of his time.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.