An error occurs during compilation:
Error: cast from 'Char * 'to 'int' loses precision
Cause: the program exists.
Char * addrCom; addrCom =... // assign the value if (-1 = (int) addrCom) // causes a compilation error {......}
The above is implicit conversion. Change it to Standard C ++ display type conversion: static_cast <int> or this is reinterpret_cast <int>
Still:
Error: cast from 'Char * 'to 'int' loses precision
Finally google a bit, found the answer: http://stackoverflow.com/questions/1640423/error-cast-from-void-to-int-loses-precision
ShouldChange (int) addrCom to (long) addrComYou can.
Explanation:
Because the compiled system is linux64-bit, the pointer type is equal to the long type (8B) and the int type 4B, the loses precision will appear.
Therefore, first convert char * --> long, and then convert it from long to int automatically and implicitly.