结构和指针错误:取消引用指向不完整类型的指针

时间:2014-05-19 03:03:19

标签: c pointers struct casting

好的我有三个结构:

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,},};

上述工作没有错误.... 但是当我尝试在我的init_C614L8.c中初始化上面的无线电时... 使用以下代码我收到错误... 错误:在第4行和第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++ ) {

我想我必须投一些东西,但不要害羞 感谢

2 个答案:

答案 0 :(得分:4)

rss.h中声明

struct radio_s_C614L8

但在init_C614L8.c中使用

struct radio_s_614L8

无处宣称。

<强>更新

修复此错误

  

错误:取消引用指向不完整类型的指针

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

struct radio_s_614L8

通过

struct radio_s_C614L8

这里吸取的教训是去买一些眼镜或者睡一觉! ;-)而且:&#34;编译器永远不会说谎!&#34;

答案 1 :(得分:0)

这意味着struct radio_s_614L8的定义对于看到错误的代码是不可见的。您忘记了include定义,或者#if...指令删除了您认为存在的定义或include