Question

This is my header file:

typedef int* Arg;   
typedef int* Args[];
typedef int** ArgsList[];

typedef int (*ProcessStart)(Args);

typedef struct PCBEntry{

    ProcessStart proc;
    Args args;
    int pid;
    int curr_proc;
    int sched_info;
    int pc;

} PCBEntry;

I get the error on the Args argsline in the struct and I have no idea why.

Was it helpful?

Solution

Because you defined Args as int *[], the member args is effectively declared as

int *args[];

This is a flexible array member, and they are only allowed at the end of a structure.

If you meant to imply that Args was a pointer (in the same vein as char **argv), declare it as a pointer:

typedef int **Args;

OTHER TIPS

Rather than using

typedef int* Args[];

and in your structure declaration

Args args;

you would be better served to just use the first type for your structure declaration...

Arg args[];

To be honest, I'm not even sure the the first one is a legal typedef, but it's only that I've never ever done anything like that with a typedef before. My gut tells me that it's not legal and therefore Args is undefined and thus the error you're getting. If I apply the right-left rule to that, then Args is a type that is an array of pointers to int... so, maybe it's legal, but it sure reads funny to my eye.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top