Reputation: 396
Because I like torturing myself, after I ported GCC 4.7 to Android I decided to immediately try porting GCC 4.8 to Android.
I ran into the following error during the libcpp portion of the build:
../../gcc-4.8/libcpp/files.c:725:27: error: cannot convert 'long long int*' to 'off_t* {aka long int*}' for argument '7' to 'unsigned char* _cpp_convert_input(cpp_reader*, const char*, unsigned char*, size_t, size_t, const unsigned char**, off_t*)'
My question is: Should this conversion be possible?
EDIT: I'd originally posted an answer that a cast needed to be written instead of relying on implicit conversion, but I deleted it in light of the problems I've been having after doing just that.
Here's the original problematic code:
file->buffer = _cpp_convert_input (pfile,
CPP_OPTION (pfile, input_charset),
buf, size + 16, total,
&file->buffer_start,
&file->st.st_size);
Here's the cast I tried (NOTE: I have only a rudimentary understanding of C):
off_t ot = (off_t) file->st.st_size
Using the cast above results in a "Bad address" error from the cc1 binary when run on the target device.
Upvotes: 2
Views: 842
Reputation: 396
Once again, 24 hours after I ask the question the answer turns up.
NOTE: The following is from 24 hours worth of C language parsing...if any of it is incorrect please feel free to comment.
A "narrowing" conversion is the same as an "implicit" conversion, which apparently is not allowed in Android native development, or not possible with the Bionic libc...I'm not sure which. Therefore, in order for the function in files.c to work, the long long int passed to _cpp_convert_input needs to be cast to off_t.
I added the cast to files.c as a workaround; if the build works I'll update this answer with it.
EDIT: Unfortunately the cast I added did NOT work...the build completed but the resulting binary threw a "bad address" when run on the device. I'll post the modification to a different question.
EDIT: A cast works...I just didn't write it correctly. Thanks and kudos to Jonathan Wakely who corrected this:
off_t ot = (off_t) file->st.st_size
funct(*args*, &ot)
into this:
off_t ot = (off_t) file->st.st_size;
funct(*args*, &ot);
file->st.st_size = ot;
That plus another explicit cast added to macro.c plus edits to gengtype.c, gcc/Makefile.in and double-int.h allowed the build to complete and the binaries to run on-device.
Upvotes: 1