__stdcall typedef g++问题

发布于 2024-10-09 20:35:11 字数 526 浏览 0 评论 0原文

这段代码编译(正如我所期望的):

typedef void __stdcall (*Func)();

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

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

但是这个:

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

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

失败并出现不是很有帮助的错误消息:

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

我在 Vista 下使用 g++ 3.4.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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

兲鉂ぱ嘚淚 2024-10-16 20:35:11

语法是 void(__stdcall *)(),而不是 void __stdcall (*)()

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文