当前位置:网站首页>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;
}

边栏推荐
- FileZilla搭建FTP服务器图解教程
- Ehrlich screening method: Counting the number of prime numbers
- TRUNCATE表之后空间未释放
- 发送激活邮件「建议收藏」
- Technology Sharing | How to use the JSON Schema mode of interface automation testing?
- [Cloud Native] 4.2 DevOps Lectures
- Interpretation of the paper (DropEdge) "DropEdge: Towards Deep Graph Convolutional Networks on Node Classification"
- Cookie, session, token
- 阿里云架构师金云龙:基于云XR平台的视觉计算应用部署
- 阿里云架构师金云龙:基于云XR平台的视觉计算应用部署
猜你喜欢

Xiaohei leetcode's refreshing rainy day trip, just finished eating Yufei Beef Noodles, Mala Tang and Beer: 112. Path Sum

shell学习

肝通宵写了三万字把SQL数据库的所有命令,函数,运算符讲得明明白白讲解,内容实在丰富,建议收藏+三连好评!

2022 首期线下 Workshop!面向应用开发者们的数据应用体验日来了 | TiDB Workshop Day

AI+Medical: Using Neural Networks for Medical Image Recognition and Analysis

ACM MM 2022 | Cloud2Sketch: Painting with clouds in the sky, AI brush strokes

leetcode 39. 组合总和(完全背包问题)

How to Make Your Company Content GDPR Compliant

xctf攻防世界 Web高手进阶区 ics-05

17-GuliMall 搭建虚拟域名访问环境
随机推荐
Js fifteen interview questions (with answers)
Cookie, session, token
为什么这么多人都想当产品经理?
Leetcode 93 IP addresses
Flask入门学习教程
Jinshanyun earthquake, the epicenter is in bytes?
接口自动化测试实践指导(上):接口自动化需要做哪些准备工作
大型分布式存储方案MinIO介绍,看完你就懂了!
js array object deduplication
The round functions in the np, ceil function and floor function
用户代码未处理MetadataException
17-GuliMall 搭建虚拟域名访问环境
2022年中国第三方证券APP创新专题分析
2022 首期线下 Workshop!面向应用开发者们的数据应用体验日来了 | TiDB Workshop Day
NIO Cup 2022 Nioke Summer Multi-School Training Camp 7 CFGJ
Domestic mobile phone manufacturers once fought for it, but now it is the first to collapse...
SQLi-LABS Page-2 (Adv Injections)
Leetcode 93 复原IP地址
openGauss数据库基本操作(超详细)
PHP 2D array sorted by a field