저는 C로 벡터를 쓰고 있습니다. CVectorSearch 함수는 정렬되어 있으면 bsearch를 사용하고 정렬되지 않은 경우에는 lfind를 사용합니다. lfind를 호출 할 때 "할당이 캐스트없이 정수에서 포인터를 만듭니다"라는 경고 메시지가 나타나는 이유는 무엇입니까? lfind가 사용될 때조차도 제대로 작동하는 것 같습니다.lfind를 호출 할 때 정수없이 캐스팅 경고가 나타납니다
typedef struct
{
void *elements;
int logicalLength;
int allocatedLength;
int elementSize;
} CVector;
typedef void (*CVectorFreeElemFn)(void *elemAddr);
int CVectorSearch(const CVector *v, const void *key,
CVectorCmpElemFn comparefn,
int startIndex, bool isSorted)
{
void * found;
int elemSize = v->elementSize;
int length = v->logicalLength;
void *startAddress = (char*)v->elements + startIndex*elemSize;
if(isSorted)
found = bsearch(key, startAddress, length, elemSize, comparefn);
else
found = lfind(key, startAddress, &length, elemSize, comparefn);
if(found)
return ((char*)found - (char*)v->elements)/elemSize;
else
return -1;
}
편집 : 지금은 내가 갖는 search.h을 포함했다고 :이 프로그램은 여전히 있지만, 제대로 작동
warning: passing argument 3 of 'lfind' from incompatible pointer type
.