__stdcall typedef g++ problem
Asked Answered
H

1

2

This code compiles (as I would expect):

typedef void __stdcall (*Func)();

struct A {
    static void __stdcall f() { }
};

int main() {
    Func p = A::f;
}

But this one:

struct A {
    typedef void __stdcall (*Func)();
    static void __stdcall f() { }
};

int main() {
    A::Func p = A::f;
}

fails with not-very-helpful error message:

error: invalid conversion from `void (*)()' to `void (*)()'

I'm using g++ 3.4.2 under Vista (I know, it's ancient, but I don't have access to any other environment right now). Obviously I am missing something here. Any help would be appreciated.

Haire answered 26/12, 2010 at 18:18 Comment(1)
What are you trying to achieve. In C ot is common to get the address of a function. in C++ it is very rare to need the address of a function or method.Krause
M
7

The syntax is void(__stdcall *)(), not void __stdcall (*)().

Museology answered 26/12, 2010 at 18:21 Comment(1)
That was a simple answer. Thank you!Haire

© 2022 - 2024 — McMap. All rights reserved.