Hi,
My project structure is as follows:
\- base (C static library)
callbacks.h
callbacks.c
paint_node.c
.
.
* libBase.a
\-app (C++ application)
main.cpp
In the 'base' C library, I declared global-function-pointer as:
in singleheader file
callbacks.h
#ifndef CALLBACKS_H_
#define CALLBACKS_H_
extern void (*putPixelCallBack)();
extern void (*putImageCallBack)();
#endif
in one C file they are initialized as
callbacks.c
#include "callbacks.h"
void (*putPixelCallBack)();
void (*putImageCallBack)();
Other C files access these callbacks as:
paint_node.c
#include "callbacks.h"
void paint_node(node *node,int index){
.
.
putPixelCallBack(node->x,node->y,index);
}
I will compile these C files and create the libBase.a static library
Then in a C ++ application
I want to assign a C ++ instance method to this global pointer function:
I did something like the following:
in the Sacm.cpp file
#include "Sacm.h"
extern void (*putPixelCallBack)();
extern void (*putImageCallBack)();
void Sacm::doDetection()
{
putPixelCallBack=(void(*)())&paintPixel;
}
void Sacm::paintPixel(int x,int y,int index)
{
qpainter.begin(this);
qpainter.drawPoint(x,y);
qpainter.end();
}
But when compiling it gives an error:
sacmtest.cpp: - 'void SACM:: doDetection(): sacmtest.cpp: 113: : ISO ++ - -. '& Sacm:: paintPixel sacmtest.cpp: 113: : 'void (Sacm::) (int, int, int) 'void ()()
?