【发布时间】:2014-07-06 21:43:21
【问题描述】:
好的,我有三个结构:
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 行和第 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++ ) {
我想我必须投一些东西,但不是 shure 谢谢
【问题讨论】:
-
你真的需要发布所有这些代码吗?包括the shortest program necessary to reproduce the problem。
-
如果我不向您展示我的代码和结构,您将如何做出明智的评论。
-
我的意思是它不够短。您真的需要发布所有字段名称,例如
power_400hz和modesw_614L8?制作一个简短的程序来重现问题。这样做可能会发现错误。 -
您是否意识到
radio_s_C614L8和tuner_s都嵌套 在rss_s中,在发布的代码中没有关闭}?正确缩进您发布的代码将显示: -
请不要在
->运算符的箭头周围发布带有空格的C代码。滥用这样的语法是不礼貌的。我知道您在创建问题时曾被要求创建 MCVE (How to create a Minimal, Complete, and Verifiable Example?) 或 SSCCE (Short, Self-Contained, Correct Example) — 我知道,因为我提出了问题。如果我们无法获取问题中的代码并在其上运行编译器,则会大大增加为您提供答案的难度。