The issue is with how you're referencing the struct type in your cast. Let me explain the problem and the solution.
The Problem
You've defined your struct with a typedef like this:
typedef struct _process {
unsigned int start_time;
unsigned int time_left;
unsigned int priority;
char id;
} process;
This creates two ways to refer to this struct type:
struct _process (the struct tag)
process (the typedef alias)
In your cast, you're using:
(struct process *)
But struct process doesn't exist! The struct tag is _process, not process.
The Solution
You have two correct options:
Option 1: Use the typedef name (recommended)
((process *)PRIONP_highest_prio->object)->priority
Notice: No struct keyword when using the typedef name.
Option 2: Use the actual struct tag
((struct _process *)PRIONP_highest_prio->object)->priority
Why This Happens
When you write:
typedef struct _process { ... } process;
You're doing two things:
- Defining a struct with the tag
_process (so it can be referred to as struct _process)
- Creating a typedef alias
process that refers to struct _process
The typedef process is a complete type name by itself - you don't use struct with it. Think of it like how you don't write int myint when declaring an integer; you just write int.
Common Pattern
Many C programmers use the same name for both the struct tag and the typedef to avoid this confusion:
typedef struct process {
unsigned int start_time;
unsigned int time_left;
unsigned int priority;
char id;
} process;
With this pattern, both struct process and process would work (though using just process is still preferred when you have the typedef).