Sunday, February 22, 2009

How to Compile OCMOCK_VALUE for the iPhone

If you're using OCMock to test your iPhone application and OCMOCK_VALUE gives you this error message:
error: syntax error before 'typeof'

Add this line to the top of your test case:
#define typeof __typeof__

What seems to be happening is that the ObjC compiler on the iPhone has renamed 'typeof' to '__typeof__'. The macro above will add the old version back in. Some Googleing seems to suggest that this is related to C99 compatibility.
Reblog this post [with Zemanta]

1 comment:

wjklos said...

Thanks! Perfect timing. Now if I can just get the rest of it to work.