简体   繁体   中英

warning: format '%ld' expects argument of type 'long int', but argument has type '__builtin_neon_di'

Wrt my this question ,I am not able to cross check the output . I am getting some wrong print statement after execution .Can someone tell me whether printf() statements are wrong or logic that I am doing is wrong .

CODE:

int64_t arr[2]  = {227802,9896688};
int64x2_t check64_2 = vld1q_s64(arr);

for(int i = 0;i < 2; i++){
    printf("check64_2[%d]: %ld\n",i,check64_2[i]);
}

int64_t way1   = check64_2[0] + check64_2[1];

int64x1_t way2 = vset_lane_s64(vgetq_lane_s64(check64_2, 0) + vgetq_lane_s64(check64_2, 1), way2, 0);

int64x1_t way3 = vadd_s64(vget_high_s64 (check64_2),vget_low_s64 (check64_2));

printf("way1 :%ld \n",way1);
printf("way2 :%ld \n",way2);
printf("way3 :%ld \n",way3);

OUTPUT:

check64_2[0]: 227802
check64_2[1]: 9896688
way1 :0 
way2 :0 
way3 :0 

WARNING:

 warning:format '%ld' expects argument of type 'long int', but argument 3 has type '__builtin_neon_di'printf("check64_2[%d]: %ld\n",i,check64_2[i]);
 warning:format '%ld' expects argument of type 'long int', but argument 2 has type 'int64_t {aka long long int}' [-Wformat=]
  printf("way1 :%ld \n",way1);
                            ^

Can somebody tell me How I can confirm the logic by using log/printf messages .

You are using NEON extensions. They are not normal variables, as they are stored in NEON registers. You need to use special function to fetch data from them. For example, to read single-lined int64 value you need to call to vget_lane_s64 . It will return normal 64-bit number which you can then fed to printf() .

And yes, for 64-bit wide variables you need "%lld" format.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM