简体   繁体   English

带有FIFO的结构

[英]struct with a FIFO

I'm having some trouble with structs.. 我在使用结构时遇到了麻烦。

I have the following code: 我有以下代码:

typedef struct filaNo{   
     Range data;   
     struct filaNo* prox; 
  }tfilaNo;                    

typedef struct tfifo {        
     tfilaNo* inicio;   
     tfilaNo* final;       
  } tfifo;  

And I want to include this list in another struct: 我想将此列表包含在另一个结构中:

typedef struct  
{
int    threadId;
    double threshold;
    double areaCalc;
    tfifo  intervalos;
}ThreadData;

When I use only tfifo it works perfectly, but when I include into ThreadData I receive 55 errors (like: "syntax error: identifier 'tfifo'"...) and so many others like this... seems like the compiler is lost. 当我仅使用tfifo时,它可以完美地工作,但是当我将其包含到ThreadData中时,我会收到55个错误(例如:“语法错误:标识符'tfifo'” ...)以及许多其他类似内容……似乎编译器丢失了。

Does anyone know how to solve this? 有谁知道如何解决这个问题?

Thank you very much! 非常感谢你!

EDIT: some more code :) 编辑:更多代码:)

tfifo works fine alone, I can do something like this: tfifo一个人可以正常工作,我可以做这样的事情:

tfila doc;                                     
Range range;
int a;   

create_fifo(&doc);      

range.p1.x = 0;
range.p2.x = 33;
range.p1.y = 0;
range.p2.y = 0;
range.area = 0;

insert_fifo (&doc, range);   

while(!empty_fifo(doc)){   
    remove_fifo(&doc,&range);         
    printf("    %d\n", range.p2.x);   
}        

Now I want to include this into ThreadData, because I need a list for every ThreadData struct. 现在,我想将其包含在ThreadData中,因为我需要每个ThreadData结构的列表。

Error 2 error C2059: syntax error : '}' Error 1 error C2061: syntax error : identifier 'tfila' 错误2错误C2059:语法错误:'}'错误1错误C2061:语法错误:标识符'tfila'
Error 18 error C2065: 'i' : undeclared identifier 错误18错误C2065:“ i”:未声明的标识符

But the compiler gets totally lost after this... giving me so many errors that doesn't exist... 但是之后,编译器完全迷失了……给了我很多不存在的错误……

Is this the real code or a typo? 这是真实代码还是错字?

typedef struct tfifo {        
 tfilaNo* inicio;   
 tfilaNo* final;       

} tfifo; } tfifo;

You are using the same name for the struct and the typedef. 您为结构和typedef使用相同的名称。 Maybe this is the problem. 也许这就是问题所在。

In C , you need Use like this 在C中,您需要像这样使用

typedef struct struct_name
{
//...
}mytype_t;

Modify this 修改这个

typedef struct give_some_name  
{
int    threadId;
    double threshold;
    double areaCalc;
    tfifo  intervalos;
}ThreadData;  

EDIT 编辑

Here you are using same name modify this also 在这里,您使用的是相同的名称

typedef struct tfifo_t {        
     tfilaNo* inicio;   
     tfilaNo* final;       
  } tfifo;  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM