关于Linux下C编译错误(警告)cast from 'void*' to 'int' loses precision
2016-11-09 15:33
351 查看
[cpp] view
plain copy
char *ptr; //此后省略部分代码
if( (int)ptr==-1 ) //出错地方
那句话的意思是从 void* 到 int 的转换丢失精度,相信看到解释有些人就明白了,
a37e
此问题只会出现在X64位的Linux上,因为在64位的机器上指针占用8个字节,int 占用四个字节,所以才会出现这样的问题,
解决方法:
(long)ptr == -1 就好了
转载地址:http://blog.csdn.net/u011435712/article/details/41595539
plain copy
char *ptr; //此后省略部分代码
if( (int)ptr==-1 ) //出错地方
那句话的意思是从 void* 到 int 的转换丢失精度,相信看到解释有些人就明白了,
a37e
此问题只会出现在X64位的Linux上,因为在64位的机器上指针占用8个字节,int 占用四个字节,所以才会出现这样的问题,
解决方法:
(long)ptr == -1 就好了
转载地址:http://blog.csdn.net/u011435712/article/details/41595539
相关文章推荐
- 关于Linux下C编译错误(警告)cast from 'void*' to 'int' loses precision
- 关于Linux下C编译错误(警告)cast from 'void*' to 'int' loses precision
- ndk-build编译64位.so,出现ndk error: cast from 'int*' to 'int' loses precision [-fpermissive]
- x86_64 xercexc: error: cast from 'const void*' to 'long int' loses precision [-fpermissive]
- Linux系统平台下关于GCC编译及使用的方法(-Werror,它要求GCC将所有的警告当成错误进行处理 )
- Linux系统平台下关于GCC编译及使用的方法 (-Werror,它要求GCC将所有的警告当成错误进行处理
- iOS 当用到第三方的文件的时候,警告 implicit conversion loses integer precision:'long' to 'int '
- 关于Linux环境编译错误:“undefined reference to" 的原因总结
- cast from 'void *' to 'int' loses precision
- G++编译错误 no matching function for call to '_tag_data_value::StringAddLen(std::string, int, int)
- error: cast from ‘char*’ to ‘int’ loses precision
- linux 编译错误:undefined reference to `__gxx_personality_v0'
- 关于Linux驱动的一种错误:Unable to handle kernel paging request at virtual address
- 关于arm-linux-gcc交叉编译工具链,实现自己的crt0或者编译UBOOT出现undefined reference to `__aeabi_unwind_cpp_pr0'的解决方法
- Linux系统平台下关于GCC编译及使用的方法(-Werror,它要求GCC将所有的警告当成错误进行处理 )
- 怎么去掉Xcode工程中的某种类型的警告 Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int32
- 关于编译Lambda时报告返回的为void的错误
- gcc编译错误(invalid conversion from 'int' to enum)
- Linux GCC编译警告:Clock skew detected. 错误解决办法
- 关于Amdroid 4.0编译生成Recovery的一个错误:ValueError: too many values to unpack