CGFunctionCreate's callbacks and 64 bits compilation

Thursday, June 09 2011 @ 08:12 PM UTC

Contributed by: Admin

Before you get bitten by this one, better to know how to correct most code examples found on the net...

Most example found on Internet will show filter function with this prototype:

void filterFunction(void *info, const float *inData, float *outData)
	float *colors = info;
That's wrong once you compile in 64 bits (arch x86_64), the correct prototype is:

void filterFunction(void *info, const CGFloat *inData, CGFloat *outData)
	CGFloat *colors = info;
Using CGFloat guarantees the pointer arithmetic you may use in the body of the function yields to the correct result.