So it turns out that C++ code @encodes nil differently than C code.
Compilation Settings
@encode(typeof(nil))
ObjC
^v
ObjC++ with C++ 98 on 32 bit
i
ObjC++ with C++ 98 on 64 bit
q
ObjC++ with C++ 11 (all platforms)
*
so at the point where the encoding is recorded (which is done in a macro) the value recorded could be any of the above. At the point where the encoding is compared (as a special case in OCMBoxedReturnValueProvider.m) we are only checking the ObjC version, so when we stub a mock with andReturn(nil) in Objective C++ we get an exception about the return type and the method signature return type not matching.
So it turns out that C++ code @encodes nil differently than C code.
^v
i
q
*
so at the point where the encoding is recorded (which is done in a macro) the value recorded could be any of the above. At the point where the encoding is compared (as a special case in
OCMBoxedReturnValueProvider.m
) we are only checking the ObjC version, so when we stub a mock withandReturn(nil)
in Objective C++ we get an exception about the return type and the method signature return type not matching.