Having trouble returning a structure.
I posted about this project a about a week ago and the problem was resolved.
Since then, I have continued working on this project and have run into another problem.
Here is the error:
error: incompatible types when assigning to type ‘struct process’ from type ‘int’
Code:
struct process MM_shortest;
typedef struct process ITEMTYPE;
ITEMTYPE getLeastRemainingTime(struct node * h)
// Finds the node containing the job with the least remaining time.
// Deletes this node and returns the job
{
ITEMTYPE p = NULLPROCESS;
struct node * tmp = h;
struct node * current = h;
unsigned int shortestTime = current->item.timeLeft;
while(current!=NULL)
{
if(current->item.timeLeft <= shortestTime)
{
tmp = current;
shortestTime = current->item.timeLeft;
p = current->item;
}
current=current->prev; // go through the list backwards so, if processes have the same timeLeft,
// then the process that was in the queue first will be chosen
if(current == h)
{
del(h, tmp);
return p;
}
}
return NULLPROCESS;
}
Here is how I call getLeastRemainingTime in main:
Code:
MM_shortest = getLeastRemaingTime( MM_head ); /// THE ERROR IS ON THIS LINE
I am confused as to why the compiler is saying that an int is being returned.
Thanks for any help you can offer!