2013-12-03 4 views
4

'호환되지 않는 포인터 유형에서 할당'경고가 계속 발생하며 그 이유에 대한 단서가 없습니다.경고 : 호환되지 않는 포인터 유형에서 할당

myPageFrame pageFrames[numOfFrames]; 
myPage pages[numOfPages]; 

//in a for loop 
pageFrames[i].thePage = (myState == HOT ? (&pages[i]) : NULL); // one of the offenders 

pageFrames[i].thePage으로 무엇이든 시도하면 경고 메시지가 나타납니다. 문제

구조체는 다음과 같습니다

//algo_structs.h 
typedef struct{ 

int pageNum; 

} myPage; 

typedef struct myPage{ 

struct myPage* thePage; 
int loaded; 
int lastRef; 

} myPageFrame; 

답변

9

myPagestruct myPage 다른 유형입니다. 당신은에 struct 정의를 변경하여 그들에게 동일한 유형을 만들 수 :

typedef struct myPage { 
    int pageNum; 
} myPage; 

아니면 그냥 myPage * 대신 struct myPage * 사용할 수 있습니다.

+0

첫 번째 문제는 해결되지 않았습니다. 두 번째 않았다! 정말 고맙습니다! – user3056261

0

myPage 유형을 정의했지만 구조체 구성원이 struct myPage 인 경우 당신은 일관성이 있어야합니다. 다음은이 문제를 해결하는 한 가지 방법입니다.

typedef struct myPage{ 
    myPage* thePage; 
    int loaded; 
    int lastRef; 
} myPageFrame; 
관련 문제