iOS - 隐式转换失去整数精度'size_t'(又名'unsigned long')到'int'

时间:2014-01-31 14:51:59

标签: c++ implicit-conversion

size_t subsetBytesPerRow, subsetHeight, subsetWidth, subsetHeight;

方法调用:

(new GreyscaleLuminanceSource(subsetData, subsetBytesPerRow, subsetHeight,
                              0, 0, subsetWidth, subsetHeight));

方法声明:

GreyscaleLuminanceSource(unsigned char* greyData, int dataWidth, int dataHeight,
      int left, int top, int width, int height);

获取此警告 'size_t' (aka 'unsigned long') to 'int'。如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

只需将类型声明更改为int:

int subsetBytesPerRow, subsetHeight, subsetWidth, subsetHeight;

如果这只是为另一组警告换了一组警告,您可以将类型更改回size_t,然后在调用int时将每个参数投放到GreyscaleLuminanceSource