So if I run my program with the implementation as .m it works fine. Just changing it to .mm causes this line…
CGContextRef myContext = [[NSGraphicsContext currentContext] graphicsPort];
to throw this error…
error: invalid conversion from 'void*' to 'CGContext*'
Anyone have any ideas why just changing that would make it blow up, or how to fix it?
C++ does not allow implicit type casting from
void*. In this case, the implicit converstion fromvoid*(the return type of-[NSGraphicsContext graphicsPort]) aCGContextRefis illegal. You can make the conversion explicit like this:See this SO question for a discussion of the C++
static_castoperator.