__stdcall typedef g++ problem

余生颓废 提交于 2019-12-24 05:33:12

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/4534907/stdcall-typedef-g-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!