I am using Visual Studio and I selected the regular KMDF template. However, when everything loaded up, I noticed that I was getting errors saying, "cannot open source file "queue.tmh"". This error persisted across all 3 C classes where each file included a Trace Message Header File with the name being the same as the C class (just with the first letter being lowercase). However, after looking it up I learned that I needed to build the driver since that would auto generate these .tmh files (which it did). This then resolved the dependency issue besides from TRACE_DRIVER which is still apparently undefined. It still builds properly but I can't find any reference to TRACE_DRIVER and I am concerned it could cause issues. So how exactly can I resolve this dependency since it seems to not be present in the .tmh file or anywhere inside of the headers.
On a separate note, when exactly do I need to include a tmh file? For example, if I created a new C class and make a header for that class would I instead need to include that header, include the tmh file or do both? I am slightly confused here because it's done both ways. For example, in Queue.C it just includes the tmh file as Queue.tmh while Driver.c includes Driver.h and Driver.tmh why is this? When do I need to include one vs the other? Based on the following doccument I figure that I only need to to include tmh if I use a WPP macro. But that still does not answer why Driver.C includes both. I was reading about trace message headers here, but I ran into a roadblock by not being able to answer the rest of my questions https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/trace-message-header-file
NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
{
WDF_DRIVER_CONFIG config;
NTSTATUS status;
WDF_OBJECT_ATTRIBUTES attributes;
//
// Initialize WPP Tracing
//
WPP_INIT_TRACING(DriverObject, RegistryPath);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
The issue is with TRACE_DRIVER being undefined.