KMDF工程新增source文件出现的"TraceEvents未定义”编译错误
2016-04-26 14:40
627 查看
问题引入:在windows驱动开发过程中,我们一般会用VS2015+WDK10,新建一个KMDF工程(非empty)。该过程可参考我的另一篇博客:点击打开链接。这个工程新建好了,并能编译通过,但有时我们需要在该工程中新增source文件。通过在VS中“添加现有项"或”新增加项“的方式添加一个或几个新的源文件到工程中。然后再编译,会报错”error
C4013: “TraceEvents”未定义;假设外部返回 int“等与”TraceEvents“相关的错误。
参考微软的官方文档:WPP。TraceEvents隶属于WPP,是WDF中的日志打印相关的宏。如下:
The trace message header (.tmh) file must be included in a source file
before any WPP macro calls and after defining a WPP_CONTROL_GUIDS
macro (defined in toaster.h). During the compilation, WPP scans the source
files for DoTraceMessage() calls and builds a .tmh file which stores a unique
data GUID for each message, the text resource string for each message,
and the data types of the variables passed in for each message. This file
is automatically generated by the WPP preprocessor.
以上这段注释,说明:在使用TraceEvents之前,需要先包含”.tmh“文件。该文件由WPP预处理器生成。
参考我的另一篇博客:点击打开链接
但是,这次出现的这个编译错误是在包含了改文件之后,还存在。
解决办法:
右键新添加的source文件,添加如下内容:
注:
从前面所说的微软官方文档可以知道:
You can use any trace message function you choose, provided the trace message function, the trace flags, and levels are defined appropriately. The default trace message function is the DoTraceMessage macro.
You can add this macro to your code to write messages to the log file. The following table lists some of the predefined trace message functions and the debug print functions you can use to create trace messages.
默认的trace msg生成函数是”DoTraceMessage“,它没有信息分级和分标志。要使用TraceEvents,需要按上述的方式自行指定,否则编译出错。
C4013: “TraceEvents”未定义;假设外部返回 int“等与”TraceEvents“相关的错误。
参考微软的官方文档:WPP。TraceEvents隶属于WPP,是WDF中的日志打印相关的宏。如下:
The trace message header (.tmh) file must be included in a source file
before any WPP macro calls and after defining a WPP_CONTROL_GUIDS
macro (defined in toaster.h). During the compilation, WPP scans the source
files for DoTraceMessage() calls and builds a .tmh file which stores a unique
data GUID for each message, the text resource string for each message,
and the data types of the variables passed in for each message. This file
is automatically generated by the WPP preprocessor.
以上这段注释,说明:在使用TraceEvents之前,需要先包含”.tmh“文件。该文件由WPP预处理器生成。
参考我的另一篇博客:点击打开链接
但是,这次出现的这个编译错误是在包含了改文件之后,还存在。
解决办法:
右键新添加的source文件,添加如下内容:
注:
从前面所说的微软官方文档可以知道:
Step 5: Instrument the driver code to generate trace messages at appropriate points
You can use any trace message function you choose, provided the trace message function, the trace flags, and levels are defined appropriately. The default trace message function is the DoTraceMessage macro.You can add this macro to your code to write messages to the log file. The following table lists some of the predefined trace message functions and the debug print functions you can use to create trace messages.
默认的trace msg生成函数是”DoTraceMessage“,它没有信息分级和分标志。要使用TraceEvents,需要按上述的方式自行指定,否则编译出错。
相关文章推荐
- OSATOMIC与synchronized 加锁的对比
- 照片预览的scrollView控件
- 【BZOJ2152】聪聪可可,dfs+递推/点分治
- Mysql rpm包安装
- MT4客户端通讯分析(一)——登录部分分析
- 如何让APP在最短的时间内成功上线?
- 解决Scrapy性能问题——案例一(CPU饱和)
- cnn中权值共享理解
- 防火墙学习随笔
- Visual Studio2010简体中文版/旗舰版安装教程
- jq中的ajax
- POJ 1830 开关问题 (01高斯消元)
- UNPv1第二十六章:数据链路访问
- CentOS安装jdk1.8 及服务器之间的拷贝
- 两天 写出简易数据库管理程序
- 以“不变应万变”,我们需要怎么做?
- androidstudio编译的时候报R.java类重复错误怎么搞
- solr源码入门1
- 构架相关
- 软件企业测试团队的组织架构