最近学习多线程,写Demo程序时,遇到一个编译器告警,就是在用 pthread_join 函数获取线程返回状态值时,出现 -Wpointer-to-int-cast 告警。下面来看一下具体是啥问题 原Demo 程序如下: #include<stdio.h>#include<stdlib.h>#include<assert.h>#include<pthread.h>void*func_1(void*);void*func_2(void...
警告信息 "cast from pointer to integer of different size [-Wpointer-to-int-cast]" 指的是在代码中进行了从指针类型到整数类型的转换,但这个转换在大小上是不匹配的。在不同的平台上,指针的大小(通常是32位或64位)和整数类型(如 int,long 等)的大小可能不同。因此,直接进行这样的转换可能会导致数据丢失...
"Cast from pointer to smaller type 'int' loses information” 从错误内容我们也能看出, 错误出在'int'这里了。 而那份代码也比較早的, 在Xcode5.1之后, 要用uintptr_t来替代int。 把错误语句处的int全换成uintptr_t就可以。 可是, 这样可能会带来很多其它的问题。
Cast from pointer to smaller type ‘int‘ loses information 当void*转换为int时,会报错: Castfrompointer to smaller type ‘int‘ loses information 后来,发现这么修改即可: (int)(size_t)data
error: cast from pointer to smaller type 'unsigned int' loses information 线程池代码上,往往需要输出对应的线程池编号,即(int) pthread_self() 但是在64为机器上可能导致因为int为4字节,指针统统为8字节,所以一般将int改成uintptr_t 即可解决。 即,将(unsigned int)强制类型转换修改成: uintptr_t 即可。
failed to build dll: exit status 1 - test.c: In function 'cdecl2': test.c:5:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] for(i=0;i<(int)n;i++){ ^ test.c:6:3: warning: passing argument 1 of 'f' makes pointer from integer without ...
formdata.c: In function 'FormAdd': formdata.c:390:21: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] array_state?(curl_off_t)array_value:va_arg(params, curl_off_t); array_valueis a 32-bit pointer,curl_off_tis a 64-bit integer. The warning is ...
D:/api/library/libwebsockets-3.2.3/lib/core-net/vhost.c:732:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] 732 | if (vh->log_fd == (int)LWS_INVALID_FILE) { | ^ D:/api/library/libwebsockets-3.2.3/lib/core-net/vhost.c:745:16: error:...
src/annoymodule.cc:182:12: error: cast from pointer to smaller type 'int' loses information return (int) NULL; ^~~~ NULL can't be converted to integer because it is a pointer. In fact, this function call and comparison are meaningl...
cairo_jpg.c:223:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] return write((long)closure, data, length) < length ? CAIRO_STATUS_WRITE_ERROR : CAIRO_STATUS_SUCCESS; cairo_jpg.c: In function 'cairo_image_surface_write_to_jpeg': cairo_jpg.c:279:...