所以我有一个
unsigned char * pMyPtr
Run Code Online (Sandbox Code Playgroud)
分配给某事.
然后我想将它与任意字符串进行比较
strcmp(const char* , const char* )
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,clang编译器告诉我
warning: passing (aka 'unsigned char *') to parameter of type 'const char *' converts between pointers to integer types with different sign
如何删除此警告?
对于这个问题的所有评论,我觉得我错过了一些东西.
我知道演员阵容不合时宜,但不是以下简单的解决方法吗?
strcmp((const char*) pMyPtr , whatever_is_being_compared)
Run Code Online (Sandbox Code Playgroud)
它甚至没有签名.在它背后,是一个结构.
这意味着你不能strcmp在这里使用.strcmp当输入数据是以null结尾的字符串时,您可以使用.当输入数据是结构时,情况并非如此.也许您应该考虑memcmp,或者您可能需要将结构作为结构进行比较.