Visual Studio 2010 c++ compiler:
error C2440: 'initializing' : cannot convert from 'void (__cdecl *)(void *,int,int)' to 'void (__cdecl *)(void *,...)'
1> None of the functions with this name in scope match the target type
Gcc 4.7.0:
error: invalid conversion from 'void (*)(void*, int, int)' to 'void (*)(void*, ...)' [-fpermissive]|
Quote Originally Posted by MrViggy
your free standing function has the wrong type to be assigned to the member 'ptr', as it should be expecting an implicit 'this' pointer
This is incorrect since he only defined and declared a free standing function pointer, so you can assign any free standing function that matches the same prototype. For example this will compile:
Code:
#include <iostream>

using namespace std;

struct Test
{
    void (*ptr)(void* p);
};

void myfunction(void* p) {}

int main()
{
    Test test = { &myfunction };

    return 0;
}
The typical this pointer problem people run into is trying to get c to call a c++ class member like:
Code:
#include <iostream>

using namespace std;

struct Test
{
    void (*ptr)(void* p);
};

class MyClass
{
public:
    void myfunction(void* p) {}
};

int main()
{
    MyClass Class;
    Test test = { &Class.myfunction };

    return 0;
}
This will complain about the missing the class pointer