【发布时间】:2013-01-28 21:58:40
【问题描述】:
我想在c/c++ 中找到一个宏,它获取结构typedef 和一个指向结构的指针作为输入并打印其所有内容:
假设我有一个名为 struct account 的结构。
struct account {
int account_number;
char *first_name;
char *last_name;
float balance;
};
我是这样使用的:
struct account my_account= {
.account_number = 321321,
.first_name = 0x12345678,
.last_name = 0,
.balance = 222 };
我想要一个在 linux kernel/c 语言中看起来像这样的宏:
PRINT_STRUCT_CONTENT(struct_type, pointer)
并打印以下内容:
my_account= {
account_number = 321321,
first_name = 0x12345678,
last_name = 0,
balance = 222
}
这个想法是在内核中有一种dir python 函数
Write a Macro to stringify the contents of a struct
Your most general C macro for printing variable values in different types
【问题讨论】:
-
我不知道你在问什么。您希望在内核中还是在 Python 中使用此功能?
标签: c++ c debugging linux-kernel printk