当前位置:网站首页>typedef和#define的花里胡哨的用法
typedef和#define的花里胡哨的用法
2022-08-09 21:54:00 【ma_de_hao_mei_le】
友链
还是在看驱动代码,看到了这个:
WDFDEVICE hDevice;
我去找WDFDEVICE
的定义
DECLARE_HANDLE( WDFDEVICE );
然后我又去找DECLARE_HANDLE
的定义
#define DECLARE_HANDLE(name) struct name##__{
int unused;}; typedef struct name##__ *name
看懂是啥意思了吗
这相当于定义了一个WDFDEVICE
结构体
#include <stdio.h>
#include <malloc.h>
#define DECLARE_HANDLE(name) struct name##__{
int unused;}; typedef struct name##__ *name
//struct WDFDEVICE__ {
// int unused;
//};
//
//typedef struct WDFDEVICE__* WDFDEVICE;
int main() {
DECLARE_HANDLE(test_struct_name);
test_struct_name test_struct = (test_struct_name)malloc(sizeof(test_struct_name__));
if (NULL == test_struct) return 0;
test_struct->unused = 123;
printf("%d\n", test_struct->unused);
return 0;
}
边栏推荐
- 发送激活邮件「建议收藏」
- Interpretation of the paper (DropEdge) "DropEdge: Towards Deep Graph Convolutional Networks on Node Classification"
- 国内手机厂商曾为它大打出手,如今它却最先垮台……
- Converting angles to radians
- Swift 需求 如何防止把view重复添加到win里面
- abstract class or interface
- leetcode 38. 外观数列
- 十步以内,用小程序快速生成App!
- UML类图五种关系的代码实现[通俗易懂]
- Install win virtual machine on VMware
猜你喜欢
Synchronization lock synchronized traces the source
Flask入门学习教程
Converting angles to radians
Js fifteen interview questions (with answers)
Kubernetes Service对象
nvm下node安装;node环境变量配置
JSON 基本使用
JS Deobfuscation - AST Restoration Case
Simple questions peek into mathematics
Chatting embarrassing scenes, have you encountered it?Teach you to get the Doutu emoticon package with one click, and become a chat expert
随机推荐
十步以内,用小程序快速生成App!
js十五道面试题(含答案)
论文解读(DropEdge)《DropEdge: Towards Deep Graph Convolutional Networks on Node Classification》
4D Summary: 38 Knowledge Points of Distributed Systems
Simple questions peek into mathematics
一文让你快速了解隐式类型转换【整型提升】!
Ehrlich screening method: Counting the number of prime numbers
The overall construction process of the Tensorflow model
华为鸿蒙3.0的野望:技术、应用、生态
TRUNCATE表之后空间未释放
Kubernetes Service对象
Rust dereference
Space not freed after TRUNCATE table
AI+Medical: Using Neural Networks for Medical Image Recognition and Analysis
【软考 系统架构设计师】案例分析⑤ 质量属性和架构评估
Sudoku | Backtrack-7
面试官:Redis 大 key 要如何处理?
Install win virtual machine on VMware
Bean life cycle
Interpretation of the paper (DropEdge) "DropEdge: Towards Deep Graph Convolutional Networks on Node Classification"