vs2005 warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
2012-06-28 10:13
567 查看
查MSDN得:
size_t unsigned integer Result of sizeof operator. STDDEF.H and other include files
出现C4276 warning是因为测试 32位代码的64位兼容性问题而出现的警告,由/WP64开关控制,默认是打开的。
size_t 是针对系统定制的一种数据类型,一般是整形,因为C/C++标准只定义一最低的位数,而不是必需的固定位数。而且在内存里,对数的高位对齐存储还是低位对齐存储各系统都不一样。为了提高代码的可移植性,就有定议le 这样的数据类型。
size_t 在32位系统上定义为 unsigned int,在64位系统上定义为 unsigned long.
STDDEF.H的内容
#ifndef _SIZE_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 size_t;
#else
typedef _W64 unsigned int size_t;
#endif
#define _SIZE_T_DEFINED
#endif
解决方法:(注:本人的是vs2005)
Project ->Properties ->C/C++ ->General-> Detect 64bit Portability Issues,设置成否
size_t unsigned integer Result of sizeof operator. STDDEF.H and other include files
出现C4276 warning是因为测试 32位代码的64位兼容性问题而出现的警告,由/WP64开关控制,默认是打开的。
size_t 是针对系统定制的一种数据类型,一般是整形,因为C/C++标准只定义一最低的位数,而不是必需的固定位数。而且在内存里,对数的高位对齐存储还是低位对齐存储各系统都不一样。为了提高代码的可移植性,就有定议le 这样的数据类型。
size_t 在32位系统上定义为 unsigned int,在64位系统上定义为 unsigned long.
STDDEF.H的内容
#ifndef _SIZE_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 size_t;
#else
typedef _W64 unsigned int size_t;
#endif
#define _SIZE_T_DEFINED
#endif
解决方法:(注:本人的是vs2005)
Project ->Properties ->C/C++ ->General-> Detect 64bit Portability Issues,设置成否
相关文章推荐
- vs2005 warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
- warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
- vs2005 warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
- vs2005 warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
- warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
- How to eliminate the compile error "conversion from 'double ' to 'float ', possible loss of data"
- gcc编译错误(invalid conversion from 'int' to enum)
- How to get rid of `deprecated conversion from string constant to 'char*'` warnings in GCC?
- warning C4047: 'initializing' : 'char *' differs in levels of indirection from 'const int '
- Implicit conversion of 'int' to 'id' is disallowed with ARC
- warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
- error:error C2664: 'calc' : cannot convert parameter 2 from 'int' to 'int []' Conversion fro
- warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
- Implicit conversion from enumeration type 'enum CGImageAlphaInfo' to different enumeration type 'CGB
- Cast from pointer to smaller type 'int' loses
- warning:deprecated conversion from string constant to 'char *'
- spring mvc 数据绑定报错 Failed to convert property value of type 'java.lang.String' to required type 'int'
- invalid conversion from 'const char*' to 'UCHAR*'解决方法
- Conversion from 'void*' to pointer to non-'void' requires an explicit cast
- spring Failed to convert property value of type 'java.lang.String' to required type 'int' for proper