Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identical code generates error in one project, but not another

I am trying to reuse code from another project, but while copying the classes over, it generated a compiler error in the new project, but while it was in the other project, it worked just fine.

The error is

    Cannot initialize a parameter of type 'const uint8_t *' (aka 'const unsigned char *') with an rvalue of type 'const void *'

and the code is

    [outputStream write:[userdata bytes] maxLength:[userdata length]];

outputStream is an NSOutputStream, and userdata is an NSData object. The same code surrounding this statement is used in both projects.

Both projects are compiling for the same target OS( iOS 5.0) and archetecture(armv7), and both have identical frameworks added.

I also tried to clean the project, and build it again. Same problem.

Any help would be appreciated.

like image 720
magmastonealex Avatar asked Mar 22 '26 10:03

magmastonealex


2 Answers

In the end, this was solved by casting:

[outputStream write:(const uint8_t *)[userdata bytes] maxLength:[userdata length]];

followed by a clean and build (without cleaning, it would come up with a different error.)

like image 85
magmastonealex Avatar answered Mar 25 '26 01:03

magmastonealex


I'm guessing that the old project is using the GCC compiler, and the new project is using LLVM. So the error is coming from the Clang front-end. If you change your compiler to GCC or LLVM GCC, it should go away.

like image 36
Ell Neal Avatar answered Mar 25 '26 01:03

Ell Neal