C question: error: expected ')' before '*' token

Edit 2

Thanks for all the suggestions, I edited the code below from the suggestions. However, it still does not compile. But, nevertheless, many thanks for the help.

Edit

I apologize for not putting the pcb structure in the code snippet. There is a structure called pcb defined above the two previously published structures. Namely,

typedef struct pcb{
    UINT32 proc;
    struct pcb *link;
}pcb;

Hi,

A few minutes ago I asked about structures in C and got a quick answer. But now I am faced with another problem, namely, an error in the title of this issue. I am trying to implement a simple priority queue in C using queue arrays. However, when I try to declare a function in the pcb_pQ structure, I get the above error. I have structures clearly defined in the file I heard.

In the header file:

typedef struct pcb_Q{
    pcb *head;
    pcb *tail;
    SINT32 size;
} pcb_Q;

typedef struct pcb_pQ {
 pcb_Q queues[5];
 SINT32 size;
} pcb_pQ;

The prototype of the function in the header file:

/*priority queue operations*/
VOID pcb_pq_enqueue(pcb_pQ*, pcb*);

The impulse of the function in the .c file:

VOID pcb_pq_enqueue(pcb_pQ* pcb_pQ_p, pcb* pcb_p) {
 pcb_Q* pcb_Q_p;
 int priority;

 priority = pcb->proc_priority;
 pcb_Q_p = &pcb_pQ->queues[priority];

 pcb_enqueue(pcb_Q_p, pcb);
}

When I try to compile the above code, I get the sign "error: expected") before "*". This error indicates the signature of the function in the .c file, namely

VOID pcb_pq_enqueue(pcb_pQ* pcb_pQ_p, pcb* pcb_p) {

But I'm not sure why I get this error, can someone give me a hand? Many thanks.

+3
4

? , typedef.

, pcb_pQ, pcb ( ).


: - , :

qq.h
    typedef struct pcb {
        unsigned int proc;
        struct pcb *link;
    } pcb;

    typedef struct{
        pcb *head;
        pcb *tail;
        int size;
    } pcb_Q;

    typedef struct pcb_pQ {
        pcb_Q queues[5];
        int size;
    } pcb_pQ;

    void pcb_pq_enqueue(pcb_pQ*, pcb*);

qq.c:
    #include <stdio.h>
    #include "qq.h"
    void pcb_pq_enqueue(pcb_pQ *pcb_pQ, pcb *pcb) {}
    int main (void) { return 0; }

( pcb ). , , , struct pcb.


, , - . GCC .

, .

, pcb. . , , , ,

    typedef struct {
        unsigned int proc;
        struct pcb *link;
    } pcb;

struct pcb, pcb ( , ).

+2

, pcb.

0

-, " void" " VOID" ,

#define VOID void

,

typedef struct tag_struct_pcb_Q {
    pcb *head;
    pcb *tail;
    SINT32 size;
} pcb_Q;

typedef struct tag_structpcb_pQ {
 pcb_Q queues[5];
 SINT32 size;
} pcb_pQ;

'C' , .

, .

#define VOID

VOID pcb_pq_enqueue (pcb_pQ * pcb_pQ, pcb * pcb) {

where is pcb ? it is not good to have pcb * pcb . ALWAYS specify a different name for the variable type and variable name

0
source

Edit:

typedef struct{
    UINT32 proc;
    struct pcb *link;
}pcb;

at

typedef struct pcb {
    UINT32 proc;
    struct pcb *link;
} pcb;
0
source

Source: https://habr.com/ru/post/1746815/


All Articles