已经缩小转换误差在Android NDK C ++手臂 [英] Have narrowing conversion error in C++ arm from Android NDK
本文介绍了已经缩小转换误差在Android NDK C ++手臂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经从Android的NDK C ++手臂收缩转换错误。
拥有以下code:
int16_t AX = li.A.x,AY = li.A.y;
int16_t BX = li.B.x,通过= li.B.y;
Rect16 RCA = {斧 - 8,AY - 8时,AX + 8,+ AY 8};
Rect16 RCB = {BX - 8日,由 - 8,BX + 8,+由8};
和得到这个错误,当尝试编译:
错误:的缩小转换(((int)的AY)+ -0x00000000000000008)'从'诠释'到'int16_t里面{}
Rect16结构:
typedef结构tagRect16 {
int16_t左,上,右,下;
} Rect16;
8 编译器说 -
解决方案
您的问题的事实,在EX pression 唉茎您正在呼叫
INT操作符(INT,INT)
。你需要告诉编译器8是一个短,使用方法像的这个问题。
I have narrowing conversion error in C++ arm from Android NDK.
Have a following code:
int16_t ax = li.A.x, ay = li.A.y;
int16_t bx = li.B.x, by = li.B.y;
Rect16 rcA = { ax - 8, ay - 8, ax + 8, ay + 8 };
Rect16 rcB = { bx - 8, by - 8, bx + 8, by + 8 };
And get this error, when try to compile:
error: narrowing conversion of '(((int)ay) + -0x00000000000000008)' from 'int' to 'int16_t' inside { }
Rect16 struct:
typedef struct tagRect16 {
int16_t left, top, right, bottom;
} Rect16;
解决方案
Your problem stems from the fact that in the expression ay - 8
the compiler says you are calling int operator-(int, int)
. You need to tell the compiler that 8 is a short, using a method like in this question.
这篇关于已经缩小转换误差在Android NDK C ++手臂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文