在linux内核的mido_busc文件中有struct gpio_desc gpiod;而gpio_desc这个结构体中有一个const char name;如何读出这个name的值?使用如下方法报错:error invalid use of undefined type ‘struct gpio_desc’ 示例代码struct gpio_desc gpiod;const char name;
要读取name成员的值,需要先定义一个与struct gpio_desc结构体相同的结构体或者使用struct gpio_desc结构体的定义。这可以通过包含适当的头文件来实现。例如,如果你使用的是Linux内核,你可以包含linux/gpio/driver.h头文件:
#include <linux/gpio/driver.h>
struct gpio_desc *gpiod;
const char *name;
// 使用gpiod变量的代码位置
// ...
// 读取name成员的值
name = gpiod->name;
// 将name成员的值打印到终端
printf("The name is: %s\n", name);
请确保已经正确配置了编译环境,并且已经包含了适当的头文件。
原文地址: http://www.cveoy.top/t/topic/ixFN 著作权归作者所有。请勿转载和采集!