error: invalid use of undefined type 'Row struct'

0

I am implementing a queue to control the threads created, in C . So while the thread is not the first in the queue it waits to be terminated.

example:

//
//  Enquanto não é primeira da fila
//
while(idd   !=  PPFila.dados[PPFila.primeiro])
{

    //
    //  Aguarda
    //
    GEDI_CLOCK_Delay(50);
}

and in this line while(idd != PPFila.dados[PPFila.primeiro]) displays the following error: error: error: invalid use of undefined type 'struct Fila .

Excerpts:

Struct:

struct  Fila
{

    int         capacidade;
    int         *dados;
    int         primeiro;
    int         ultimo;
    int         nItens;

};

Function:

void            funcao
            (
                char    *as_comando_buffer,
                int     an_codigo_retorno,
                char    *as_output,
                int     an_output_lenght,
                int     idd
            )

obs, I'm using them from another file with extern

extern  struct  Fila
PPFila,
AUTFila;

Does anyone have any tips how can I resolve this?

    
asked by anonymous 27.07.2016 / 13:15

1 answer

1
___ erkimt ___ error: invalid use of undefined type 'Row struct' ______ qstntxt ___

I am implementing a queue to control the threads created, in extern . So while the .h is not the first in the queue it waits to be terminated.

example:

{

    int         capacidade;
    int         *dados;
    int         primeiro;
    int         ultimo;
    int         nItens;

} Fila;

and in this line .h displays the following error: error: .c .

Excerpts:

Struct:

Fila PPFila, AUTFila;

Function:

{

    int         capacidade;
    int         *dados;
    int         primeiro;
    int         ultimo;
    int         nItens;

} Fila;

obs, I'm using them from another file with #include "fila.h"

Fila PPFila, AUTFila;

Does anyone have any tips how can I resolve this?

    
______ ___ azszpr142939

struct indicates functions or variables that are in other files - but does not give any hint to the compiler what a function's signature is, or, in the case of structs, its size and its actual structure. >

In order to use a struct, each .C file when compiled must "see" the statement of the struct. This is done by placing the statement of the struct in a header file ( %code% ) - and including that %code% file in all %code% files that you are going to compile.

In short: put your struct statement in a separate .h file (for example, "queue.h"), and in both the file where you create the global structures and the file where your error occurred, use the directive %code% .

What I see in large and recent projects is also the custom to always create a typedef with a struct - so as to dispense with the use of the word %code% in declarations of such structures (and perhaps a few more advantages to the compiler and adjacent tools can optimize your code). Then the ".h" file would contain:

typedef struct _Fila

%pre%

And then to declare PPFila and AUTFila (in the .c file)

%pre%     
___
27.07.2016 / 17:14