Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > Compile error after adding #define WPP_GLOBALLOGGER

Reply
Thread Tools Display Modes

Compile error after adding #define WPP_GLOBALLOGGER

 
 
John Bond
Guest
Posts: n/a

 
      11-30-2009
My driver is currently using WPP tracing to assist my development and
debugging. I need to see details that occur early, and decided to attempt
using the Global Logger Session. After reading several related pages, I
added the #define WPP_GLOBALLOGGER to my trace.h file after the #define
WPP_CONTROL_GUIDS macro definition.

I now get the following compile error in only the .cpp file that has the
WPP_INIT_TRACING macro call (SwrxDriver.cpp in the DriverEntry function):

....SwrxDriver.tmh(2048) : error C2664: 'RtlStringFromGUID' : cannot convert
parameter 1 from 'LPCGUID' to 'const GUID &'

When I commend out the #define WPP_GLOBALLOGGER macro, the driver compiles
without comment.

Any suggestions? John Bond
 
Reply With Quote
 
 
 
 
Doron Holan [MSFT]
Guest
Posts: n/a

 
      11-30-2009
try wrapping the #include of the tmh file in an extern "C" { } block

d

--

This posting is provided "AS IS" with no warranties, and confers no rights.


"John Bond" <> wrote in message
news:BE215B0A-B743-4D34-83A1-...
> My driver is currently using WPP tracing to assist my development and
> debugging. I need to see details that occur early, and decided to attempt
> using the Global Logger Session. After reading several related pages, I
> added the #define WPP_GLOBALLOGGER to my trace.h file after the #define
> WPP_CONTROL_GUIDS macro definition.
>
> I now get the following compile error in only the .cpp file that has the
> WPP_INIT_TRACING macro call (SwrxDriver.cpp in the DriverEntry function):
>
> ...SwrxDriver.tmh(2048) : error C2664: 'RtlStringFromGUID' : cannot
> convert
> parameter 1 from 'LPCGUID' to 'const GUID &'
>
> When I commend out the #define WPP_GLOBALLOGGER macro, the driver compiles
> without comment.
>
> Any suggestions? John Bond


 
Reply With Quote
 
John Bond
Guest
Posts: n/a

 
      11-30-2009
Thx Doron, but I still get the same compile error:

----------------------------------------------------code
snippet-----------------------------
//SwrxDriver.cpp -- driver entry points for SmartWORKS updated for KMDF
driver model

//Created 21 August 2009, Copyright (c) 2009 AudioCodes, Inc. All rights
reserved.
// Started with shell of MT2HAdriver which used pcidrv and plx9x5x example
code from the WDF samples
// Updated 18 September 2009 with code to create single fixed-name IOCTL
target for the driver.

//include the precompiled header file
#include "precomp.h"
#define WPP_GLOBALLOGGER

//*.tmh - trace message headers generated by the WPP preprocessor must
preceed WPP macro calls
// which requires that WPP_CONTROL_GUIDS macro be defined earlier, see
precomp.h
// This is required to support TraceEvents(level, flags, msg, ...) trace
statements.
// The name "TraceEvents" is defined in the sources file under the RUN_WPP
build directive
extern "C" {
#include "SwrxDriver.tmh"
}
------------------------------------------------end code
snippet-----------------------------

-----------------------SwrxDriver.tmh generated header
snippet-------------------------
#ifdef WPP_GLOBALLOGGER
#define DEFAULT_GLOBAL_LOGGER_KEY L"WMI\\GlobalLogger\\"
#define WPP_TEXTGUID_LEN 38
#define GREGVALUENAMELENGTH (18 + WPP_TEXTGUID_LEN) //
wslen(L"WMI\\GlobalLogger\\") + GUIDLENGTH

WPPINIT_EXPORT
void WppInitGlobalLogger(
__in LPCGUID ControlGuid,
__out PTRACEHANDLE LoggerHandle,
__out PULONG Flags,
__out PUCHAR Level
)
{
WCHAR GRegValueName[GREGVALUENAMELENGTH];
RTL_QUERY_REGISTRY_TABLE Parms[3];
ULONG CurrentFlags = 0;
ULONG CurrentLevel = 0;
ULONG Start = 0;
NTSTATUS Status;
ULONG Zero = 0;
UNICODE_STRING GuidString;


PAGED_CODE();

WppDebug(0,("WPP checking Global Logger\n"));


//
// Fill in the query table to find out if the Global Logger is Started
//
// Trace Flags
Parms[0].QueryRoutine = NULL;
Parms[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
Parms[0].Name = L"Start";
Parms[0].EntryContext = &Start;
Parms[0].DefaultType = REG_DWORD;
Parms[0].DefaultData = &Zero;
Parms[0].DefaultLength = sizeof(ULONG);
// Termination
Parms[1].QueryRoutine = NULL;
Parms[1].Flags = 0;
//
// Perform the query
//

Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL |
RTL_REGISTRY_OPTIONAL,
DEFAULT_GLOBAL_LOGGER_KEY,
Parms,
NULL,
NULL);
if (!NT_SUCCESS(Status) || Start == 0 ) {
return;
}

// Fill in the query table to find out if we should use the Global logger
//
// Trace Flags
Parms[0].QueryRoutine = NULL;
Parms[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
Parms[0].Name = L"Flags";
Parms[0].EntryContext = &CurrentFlags;
Parms[0].DefaultType = REG_DWORD;
Parms[0].DefaultData = &Zero;
Parms[0].DefaultLength = sizeof(ULONG);
// Trace level
Parms[1].QueryRoutine = NULL;
Parms[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
Parms[1].Name = L"Level";
Parms[1].EntryContext = &CurrentLevel;
Parms[1].DefaultType = REG_DWORD;
Parms[1].DefaultData = &Zero;
Parms[1].DefaultLength = sizeof(UCHAR);
// Termination
Parms[2].QueryRoutine = NULL;
Parms[2].Flags = 0;


RtlCopyMemory(GRegValueName, DEFAULT_GLOBAL_LOGGER_KEY,
(wcslen(DEFAULT_GLOBAL_LOGGER_KEY)+1) *sizeof(WCHAR));

Status = RtlStringFromGUID(ControlGuid, &GuidString);
----------------------------------------end at line 2048 of
SwrxDriver.tmh----------------

The last line is the point of the compile error... hope this helps.

John Bond
 
Reply With Quote
 
Ivan Brugiolo [MSFT]
Guest
Posts: n/a

 
      11-30-2009
I guess your driver is compiled with __cpluplus defined.
That would #define REFGUID differently.
It is not clear (unless you analyze the output of `cl.exe /showIncludes`)
who first defines _REFGUID_DEFINED and/or if your precompiled header
can be wrapped with #ifndef __cplusplus/extern "C" {/#endif.
Try to have the header that first defines REFGUID
to be trated as a C compilation unit.

Good Luck with header reshuffling.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"John Bond" <> wrote in message
news:55F6CB4D-9543-40CA-9EA5-...
> Thx Doron, but I still get the same compile error:
>
> ----------------------------------------------------code
> snippet-----------------------------
> //SwrxDriver.cpp -- driver entry points for SmartWORKS updated for KMDF
> driver model
>
> //Created 21 August 2009, Copyright (c) 2009 AudioCodes, Inc. All rights
> reserved.
> // Started with shell of MT2HAdriver which used pcidrv and plx9x5x
> example
> code from the WDF samples
> // Updated 18 September 2009 with code to create single fixed-name IOCTL
> target for the driver.
>
> //include the precompiled header file
> #include "precomp.h"
> #define WPP_GLOBALLOGGER
>
> //*.tmh - trace message headers generated by the WPP preprocessor must
> preceed WPP macro calls
> // which requires that WPP_CONTROL_GUIDS macro be defined earlier, see
> precomp.h
> // This is required to support TraceEvents(level, flags, msg, ...) trace
> statements.
> // The name "TraceEvents" is defined in the sources file under the
> RUN_WPP
> build directive
> extern "C" {
> #include "SwrxDriver.tmh"
> }
> ------------------------------------------------end code
> snippet-----------------------------
>
> -----------------------SwrxDriver.tmh generated header
> snippet-------------------------
> #ifdef WPP_GLOBALLOGGER
> #define DEFAULT_GLOBAL_LOGGER_KEY L"WMI\\GlobalLogger\\"
> #define WPP_TEXTGUID_LEN 38
> #define GREGVALUENAMELENGTH (18 + WPP_TEXTGUID_LEN) //
> wslen(L"WMI\\GlobalLogger\\") + GUIDLENGTH
>
> WPPINIT_EXPORT
> void WppInitGlobalLogger(
> __in LPCGUID ControlGuid,
> __out PTRACEHANDLE LoggerHandle,
> __out PULONG Flags,
> __out PUCHAR Level
> )
> {
> WCHAR GRegValueName[GREGVALUENAMELENGTH];
> RTL_QUERY_REGISTRY_TABLE Parms[3];
> ULONG CurrentFlags = 0;
> ULONG CurrentLevel = 0;
> ULONG Start = 0;
> NTSTATUS Status;
> ULONG Zero = 0;
> UNICODE_STRING GuidString;
>
>
> PAGED_CODE();
>
> WppDebug(0,("WPP checking Global Logger\n"));
>
>
> //
> // Fill in the query table to find out if the Global Logger is Started
> //
> // Trace Flags
> Parms[0].QueryRoutine = NULL;
> Parms[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
> Parms[0].Name = L"Start";
> Parms[0].EntryContext = &Start;
> Parms[0].DefaultType = REG_DWORD;
> Parms[0].DefaultData = &Zero;
> Parms[0].DefaultLength = sizeof(ULONG);
> // Termination
> Parms[1].QueryRoutine = NULL;
> Parms[1].Flags = 0;
> //
> // Perform the query
> //
>
> Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL |
> RTL_REGISTRY_OPTIONAL,
> DEFAULT_GLOBAL_LOGGER_KEY,
> Parms,
> NULL,
> NULL);
> if (!NT_SUCCESS(Status) || Start == 0 ) {
> return;
> }
>
> // Fill in the query table to find out if we should use the Global
> logger
> //
> // Trace Flags
> Parms[0].QueryRoutine = NULL;
> Parms[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
> Parms[0].Name = L"Flags";
> Parms[0].EntryContext = &CurrentFlags;
> Parms[0].DefaultType = REG_DWORD;
> Parms[0].DefaultData = &Zero;
> Parms[0].DefaultLength = sizeof(ULONG);
> // Trace level
> Parms[1].QueryRoutine = NULL;
> Parms[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
> Parms[1].Name = L"Level";
> Parms[1].EntryContext = &CurrentLevel;
> Parms[1].DefaultType = REG_DWORD;
> Parms[1].DefaultData = &Zero;
> Parms[1].DefaultLength = sizeof(UCHAR);
> // Termination
> Parms[2].QueryRoutine = NULL;
> Parms[2].Flags = 0;
>
>
> RtlCopyMemory(GRegValueName, DEFAULT_GLOBAL_LOGGER_KEY,
> (wcslen(DEFAULT_GLOBAL_LOGGER_KEY)+1) *sizeof(WCHAR));
>
> Status = RtlStringFromGUID(ControlGuid, &GuidString);
> ----------------------------------------end at line 2048 of
> SwrxDriver.tmh----------------
>
> The last line is the point of the compile error... hope this helps.
>
> John Bond


 
Reply With Quote
 
Doron Holan [MSFT]
Guest
Posts: n/a

 
      12-03-2009
what WDK are you using? I think we fixed this in the win7 wdk.

d

--

This posting is provided "AS IS" with no warranties, and confers no rights.


"Ivan Brugiolo [MSFT]" <> wrote in message
news:OtUYm#...
> I guess your driver is compiled with __cpluplus defined.
> That would #define REFGUID differently.
> It is not clear (unless you analyze the output of `cl.exe /showIncludes`)
> who first defines _REFGUID_DEFINED and/or if your precompiled header
> can be wrapped with #ifndef __cplusplus/extern "C" {/#endif.
> Try to have the header that first defines REFGUID
> to be trated as a C compilation unit.
>
> Good Luck with header reshuffling.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> Use of any included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
>
>
> "John Bond" <> wrote in message
> news:55F6CB4D-9543-40CA-9EA5-...
>> Thx Doron, but I still get the same compile error:
>>
>> ----------------------------------------------------code
>> snippet-----------------------------
>> //SwrxDriver.cpp -- driver entry points for SmartWORKS updated for KMDF
>> driver model
>>
>> //Created 21 August 2009, Copyright (c) 2009 AudioCodes, Inc. All rights
>> reserved.
>> // Started with shell of MT2HAdriver which used pcidrv and plx9x5x
>> example
>> code from the WDF samples
>> // Updated 18 September 2009 with code to create single fixed-name IOCTL
>> target for the driver.
>>
>> //include the precompiled header file
>> #include "precomp.h"
>> #define WPP_GLOBALLOGGER
>>
>> //*.tmh - trace message headers generated by the WPP preprocessor must
>> preceed WPP macro calls
>> // which requires that WPP_CONTROL_GUIDS macro be defined earlier, see
>> precomp.h
>> // This is required to support TraceEvents(level, flags, msg, ...) trace
>> statements.
>> // The name "TraceEvents" is defined in the sources file under the
>> RUN_WPP
>> build directive
>> extern "C" {
>> #include "SwrxDriver.tmh"
>> }
>> ------------------------------------------------end code
>> snippet-----------------------------
>>
>> -----------------------SwrxDriver.tmh generated header
>> snippet-------------------------
>> #ifdef WPP_GLOBALLOGGER
>> #define DEFAULT_GLOBAL_LOGGER_KEY L"WMI\\GlobalLogger\\"
>> #define WPP_TEXTGUID_LEN 38
>> #define GREGVALUENAMELENGTH (18 + WPP_TEXTGUID_LEN) //
>> wslen(L"WMI\\GlobalLogger\\") + GUIDLENGTH
>>
>> WPPINIT_EXPORT
>> void WppInitGlobalLogger(
>> __in LPCGUID ControlGuid,
>> __out PTRACEHANDLE LoggerHandle,
>> __out PULONG Flags,
>> __out PUCHAR Level
>> )
>> {
>> WCHAR GRegValueName[GREGVALUENAMELENGTH];
>> RTL_QUERY_REGISTRY_TABLE Parms[3];
>> ULONG CurrentFlags = 0;
>> ULONG CurrentLevel = 0;
>> ULONG Start = 0;
>> NTSTATUS Status;
>> ULONG Zero = 0;
>> UNICODE_STRING GuidString;
>>
>>
>> PAGED_CODE();
>>
>> WppDebug(0,("WPP checking Global Logger\n"));
>>
>>
>> //
>> // Fill in the query table to find out if the Global Logger is Started
>> //
>> // Trace Flags
>> Parms[0].QueryRoutine = NULL;
>> Parms[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
>> Parms[0].Name = L"Start";
>> Parms[0].EntryContext = &Start;
>> Parms[0].DefaultType = REG_DWORD;
>> Parms[0].DefaultData = &Zero;
>> Parms[0].DefaultLength = sizeof(ULONG);
>> // Termination
>> Parms[1].QueryRoutine = NULL;
>> Parms[1].Flags = 0;
>> //
>> // Perform the query
>> //
>>
>> Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL |
>> RTL_REGISTRY_OPTIONAL,
>> DEFAULT_GLOBAL_LOGGER_KEY,
>> Parms,
>> NULL,
>> NULL);
>> if (!NT_SUCCESS(Status) || Start == 0 ) {
>> return;
>> }
>>
>> // Fill in the query table to find out if we should use the Global
>> logger
>> //
>> // Trace Flags
>> Parms[0].QueryRoutine = NULL;
>> Parms[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
>> Parms[0].Name = L"Flags";
>> Parms[0].EntryContext = &CurrentFlags;
>> Parms[0].DefaultType = REG_DWORD;
>> Parms[0].DefaultData = &Zero;
>> Parms[0].DefaultLength = sizeof(ULONG);
>> // Trace level
>> Parms[1].QueryRoutine = NULL;
>> Parms[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
>> Parms[1].Name = L"Level";
>> Parms[1].EntryContext = &CurrentLevel;
>> Parms[1].DefaultType = REG_DWORD;
>> Parms[1].DefaultData = &Zero;
>> Parms[1].DefaultLength = sizeof(UCHAR);
>> // Termination
>> Parms[2].QueryRoutine = NULL;
>> Parms[2].Flags = 0;
>>
>>
>> RtlCopyMemory(GRegValueName, DEFAULT_GLOBAL_LOGGER_KEY,
>> (wcslen(DEFAULT_GLOBAL_LOGGER_KEY)+1) *sizeof(WCHAR));
>>
>> Status = RtlStringFromGUID(ControlGuid, &GuidString);
>> ----------------------------------------end at line 2048 of
>> SwrxDriver.tmh----------------
>>
>> The last line is the point of the compile error... hope this helps.
>>
>> John Bond

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59