0
votes

My app uses libxml2, which contains a function "xmlReadMemory(const char * buffer, int size, const char * URL, const char * encoding, int options)"

I do have a "size" to send, but it is an NSUInteger.

This framework is written in C, so it expects me to send an int, which throws a warning in my application since I am now including arm64 as a valid architecture: "Implicit conversion loses integer precision: NSUInteger (aka 'unsigned long') to int". Is there a safe way to resolve this warning?

link to framework API: http://www.xmlsoft.org/html/libxml-parser.html

1
this seems like a similar issue too: stackoverflow.com/questions/24148817/…Chicowitz
int isize = (int) usize; if (isize < 0 || isize != usize) Handle_Error(); else xmlReadMemory(buffer, isize, URL, rncoding, options);chux - Reinstate Monica

1 Answers

1
votes

As long as you're confident that you'll never need to pass it a value larger than the largest 32 bit integer (very unlikely) just cast it to int by adding (int) in front of the parameter in the function call. An unsigned 32 bit value is over 4 GB, which is more than the memory on an iPhone, and would take HOURS to download over the cell network.