调试打印的MS标志中的奇怪值

时间:2016-02-25 10:14:55

标签: c++ c flags

我在Microsoft驱动程序代码示例中看到调试跟踪标志:

#define DEBUG_TRACE_ERROR                           0x00000001  // Errors - whenever we return a failure code
#define DEBUG_TRACE_LOAD_UNLOAD                     0x00000002  // Loading/unloading of the filter
#define DEBUG_TRACE_INSTANCES                       0x00000004  // Attach / detatch of instances

#define DEBUG_TRACE_METADATA_OPERATIONS             0x00000008  // Operation to access / modify in memory metadata

#define DEBUG_TRACE_ALL_IO                          0x00000010  // All IO operations tracked by this filter

#define DEBUG_TRACE_INFO                            0x00000020  // Misc. information

#define DEBUG_TRACE_ALL                             0xFFFFFFFF  // All flags

我知道标志应该是2的幂(如1,2,4,8,16,32)不相交。 但是为什么 DEBUG_TRACE_ALL_IO 是10而 DEBUG_TRACE_INFO 是20而不是16& 32?

2 个答案:

答案 0 :(得分:6)

因为此代码中的值是十六进制。 0x10 = 16。

答案 1 :(得分:4)

Hex: 0x00000001  0x00000002 0x00000004 0x00000008 0x0000010 0x00000020  
Dec: 1           2          4          8          16        32