warning: passing argument 1 of 'bsearch' makes pointer from integer without a cast
and the corresponding code is
Parent =bsearch((const size_t)ParentNum, ClauseVector, Size,
sizeof(CLAUSE),pcheck_CompareNumberAndClause);
the compilar is gcc.
here CLAUSE is defined as *CLAUSE.
@Paul This following more information has been added:
The change i made to the above code is :
Parent =bsearch((uintptr_t*)(size_t)(const)ParentNum,(uintptr_t*) ClauseV开发者_开发知识库ector,Size,
sizeof(CLAUSE),pcheck_CompareNumberAndClause);
After compiling i got following warning:
warning: type defaults to 'int' in declaration of 'type name'
how can i correct it?
The signature for bsearch is:
void * bsearch(const void *key, const void *base, size_t nel, size_t width, int (*compar) (const void *, const void *));
It should be pretty obvious that the first parameter (at least) in your code is incorrect.
Without seeing the rest of your code it's hard to fix this but it should probably be something like:
Parent = bsearch(&ParentNum, (void *)ClauseVector, Size,
sizeof(CLAUSE), pcheck_CompareNumberAndClause);
It would help if you posted the definitions of ParentNum, ClauseVector, Size, CLAUSE, etc.
The first argument to bsearch()
should be a pointer to a value you want to search. I don't know what ParentNum
is, but with your cast to const size_t
, it is not of a pointer type, so you get the warning. The first argument to bsearch
in your case should be a CLAUSE *
value that you want to search in ClauseVector
.
here CLAUSE is defined as *CLAUSE.
doesn't make any sense.
精彩评论