make Error: error: cast from ‘int32_t*’ {aka ‘int*’} to ‘int’ loses precision [-fpermissive]

Error message:

     xxx.h:117:59: error: cast from ‘int32_t*’ {aka ‘int*’} to ‘int’ loses precision [-fpermissive]
     int m_MinValidLen = (int)(&(((DataOnAir *)0)->rx_ts_s));

 

Reason for error:

This is because the pointer type occupies 8 bytes on the 64-bit system based on the Linux kernel, and the int type occupies 4 bytes, so there will be losses precision.

You can convert the int* to the long type first, and the long type can be implicitly converted to the int type. You can directly modify it to long long or long

Modified:

long m_MinValidLen = (long)(&(((DataOnAir *)0)->rx_ts_s));

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *