1

I am writing a file in Objc++ where I call a function of the library TooJpeg that is written in C++ and it receives a function as pointer in the first parameter, like this:

void writeByte(unsigned char byte)
{
    //....
}

- (void)foo
{
    //...
    TooJpeg::writeJpeg(writeByte, array, width, height);
}

The code above works, but I need to call a objc function instead of a C++ one, like this:

- (void)writeByte:(unsigned char)byte
{
    //....
}

- (void)foo
{
    //...
    TooJpeg::writeJpeg(writeByte, array, width, height);
}

The code above obviously does not compile.

The type of the first parameter is typedef void (*WRITE_ONE_BYTE)(unsigned char);

Any idea of what I can do to pass the function writeByte as pointer?

UPDATE:

enter image description here

The C++ code is this: https://create.stephan-brumme.com/toojpeg/

Thank you.

Pedro Paulo Amorim
  • 1,838
  • 2
  • 27
  • 50

0 Answers0