. Advertisement .
..3..
. Advertisement .
..4..
I still get the ”warning: assignment from incompatible pointer type” error while running my program and I haven’t a clue as to why.
myPageFrame pageFrames[numOfFrames];
myPage pages[numOfPages];
//in a for loop
pageFrames[i].thePage = (myState == HOT ? (&pages[i]) : NULL); // one of the offenders
The structs in question as the below:
//algo_structs.h
typedef struct{
int pageNum;
} myPage;
typedef struct myPage{
struct myPage* thePage;
int loaded;
int lastRef;
} myPageFrame;
Can someone tell me the reason for this error and the way to fix it?
The cause: This error occurs because you have a struct member of type
struct myPage
while you’ve defined a type calledmyPage
Solution: You can fix the issue by making them the same type by changing the
struct
definition to:or you could just use
myPage *
instead ofstruct myPage *
.