I tried every solution I know of, but it still give C3867 error for the way I used "callback" inside "checkexists" function. It seems I should refer to callback using pointers. How?
<OP edited their post, making this post be rendered as nonsense>
Is myclass::callback a static function? Pointers to member functions can't be used in the same way as pointers to free functions. I would just make the callback function a free (non-class) function.
Also, what do you think that this line is doing? string val = (coln[0], argv[0] ? argv[0] : "NULL");
Specifically, coln[0], argv[0]
Also, lines 27 - 29 are dead code, because you have an if-else chain that returns in both branches. You are never calling sqlite3_close, which I assume you should?
In mbozzi's code, callback_thunk is a free function, not a static member. But you should be able to use a static function as a non-class function pointer, like I showed in my example, so the original problem is something else.
I think something is wrong with the way they have been defined and implemented in .h and .cpp because as I said, if I declare and use them in main, they work fine!
OMG, I'm sorry guys. I put back and forth a lot of code and its past 3am here.
Now that I added static again in .h it worked. Now there's no error but its not doing what my original source code was doing after @mbozzi changed it. I'll look at after a few hours of sleep ;)
@mbozzi
I don't know exactly what and why you did by splitting callback, but after the error was gone, the code wasn't doing what it meant to do.
So I made some changes as below and though it all works like charm now, I don't know what's really happening between two functions and generally what you did to make it work? would appreciate your explanation here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int myClass::callback(void* data, int argc, char** argv, char**)
{
return"1" == argv[0];
}
int myClass::callback_thunk(void* data, int argc, char** argv, char** coln)
{
reinterpret_cast<myClass*>(data)->callback(NULL, argc, argv, coln);
string val = argv[0];
if (val == "1")
returntrue;
returnfalse;
}