Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Printing Line number with WDK

81 views
Skip to first unread message

Mark Scott

unread,
Apr 6, 2010, 6:48:10 AM4/6/10
to
I am trying to print the line numbers using __LINE__ in DbgPrint,
however it does not seem to be working.
I am using WDK 7600.16385.1 for x86 Windows7 build.

The statement
DbgPrint(( __LINE__ "\n" ));
results in compilation error
error C2143: syntax error : missing ')' before 'string'
warning C4047: 'function' : 'PCSTR' differs in levels of indirection
from 'int'
warning C4024: 'DbgPrint' : different types for formal and actual
parameter 1

while the statement
DbgPrint(( "%d \n", __LINE__ ));
gives the following compilation warnings (errors):
warning C4047: 'function' : 'PCSTR' differs in levels of indirection
from 'int'
warning C4047: 'function' : 'PCSTR' differs in levels of indirection
from 'int'
warning C4024: 'DbgPrint' : different types for formal and actual
parameter 1
warning C4024: 'DbgPrint' : different types for formal and actual
parameter 1


Can any one point me if there is any problem in my code (DbgPrint
statements).
I have not faced this problem with earlier versions of WDK/DDK on
Vista

Thanks,
Mark

Kalle Olavi Niemitalo

unread,
Apr 6, 2010, 6:21:08 PM4/6/10
to
Mark Scott <mrk...@gmail.com> writes:

> DbgPrint(( "%d \n", __LINE__ ));

Either use fewer parentheses or switch to KdPrint.

alberto

unread,
Apr 7, 2010, 2:23:05 PM4/7/10
to

In my driver I use __LINE__ as a parameter to RtlStringCchPrintfA and
it works fine. But I don't use any extra parenthesis, and I let my
format string issue the \n.

Hope this helps,

Alberto.

Tim Roberts

unread,
Apr 8, 2010, 1:27:35 AM4/8/10
to
Mark Scott <mrk...@gmail.com> wrote:
>
>I am trying to print the line numbers using __LINE__ in DbgPrint,
>however it does not seem to be working.
>I am using WDK 7600.16385.1 for x86 Windows7 build.
>
>The statement
>DbgPrint(( __LINE__ "\n" ));
>results in compilation error
>error C2143: syntax error : missing ')' before 'string'
>warning C4047: 'function' : 'PCSTR' differs in levels of indirection
>from 'int'
>...

>while the statement
>DbgPrint(( "%d \n", __LINE__ ));
>gives the following compilation warnings (errors):
>warning C4047: 'function' : 'PCSTR' differs in levels of indirection
>from 'int'
>...

>
>Can any one point me if there is any problem in my code (DbgPrint
>statements).

You have two problems. First, DbgPrint is a real function, and thus only
takes one set of parens. KdPrint is a macro, and requires two sets.

Second, just as the error message says, __LINE__ is an integer, not a
string. You can't pass it where a string is expected.

>I have not faced this problem with earlier versions of WDK/DDK on
>Vista

You probably used KdPrint instead of DbgPrint.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

0 new messages