gpt4 book ai didi

c - 结构和指针错误 : dereferencing pointer to incomplete type

转载 作者:太空宇宙 更新时间:2023-11-04 01:30:22 24 4
gpt4 key购买 nike

好的,我有三个结构:

struct rss_s {
Radio_types device_type; // Its device_type which is defined by the typedef above Radio_Types
char * device_info; // some thing about the radio NAV/COM/etc.
char * device_model; // the Manufactures part/model number.
char * device_serial; // the device's serial number..
int power_48v; // power to the unit..
int power_400hz;
int panel_lamps; // turn off or on the Panel Lamps only
void * radio_info;

struct radio_s_C614L8
{
loopsw_614L8 loop_sw_614L8; this is an emum
modesw_614L8 mode_sw_614L8; this is an emum
int sw_band;
int sw_bfo;
int meter;
tuner *Tuner;
int tuners;
};

typedef struct tuner_s
{
char *device_name; // OS NAME
int frequency[tuned];
int power;
int dial_lamp;
void * back_radio; // back-link to radios[n]
void * back_info; // back-link to radio_xxxx
int fd[];
} tuner;

我在 main.c 中初始化它们

// Radio 614L8
static tuner tuner_C614L8[] = {{ .device_name = "/dev/TBD", }};
static struct radio_s_C614L8 radio_C614L8 = { .Tuner = &tuner_C614L8, .tuners = DIM(tuner_C614L8) };

static struct rss_s radios[] = {
{ .device_type = C614L8,
.device_info = "ADF",
.device_model = "614L8",
.device_serial = "8384",
.radio_info = &radio_C614L8,},};

以上工作没有错误....但是当我尝试初始化上面的 radio 时...在我的 init_C614L8.c 中使用以下代码我收到错误...错误:在第 4 行和第 6 行取消引用指向不完整类型的指针

int init_C614L8( struct rss_s  * radios ){
int rw, i;
struct radio_s_614L8 * rad_info = radios -> radio_info;
tuner * this_tuner = rad_info -> Tuner;
// Now we will loop over the sub_devices....
for ( i = 0; i < rad_info -> tuners; i++ ) {

我想我必须施放一些东西但不是绝对的谢谢

最佳答案

rss.h 中声明

struct radio_s_C614L8

但是在 init_C614L8.c 中你使用

struct radio_s_614L8

无处声明。

更新:

修复这个错误

error: dereferencing pointer to incomplete type

init_C614L8.c(以及任何其他地方,但rss.h)替换

struct radio_s_614L8

通过

struct radio_s_C614L8

这里吸取的教训是要么去戴眼镜,要么睡一觉! ;-) 还有:“编译器从不说谎!”

关于c - 结构和指针错误 : dereferencing pointer to incomplete type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23729136/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com