函数指针编译错误:"*"标记之前的预期“)" [英] function pointer compilation error: expected ‘)’ before ‘*’ token

查看:86
本文介绍了函数指针编译错误:"*"标记之前的预期“)"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< code> typedef int(__stdcall * myfunc)(int);

int main(){返回0;}
</code>

#g ++ Test1.cpp
Test1.cpp:1:错误:预期在''*''标记之前的'')''

为什么?
谢谢

<code>typedef int (__stdcall * myfunc) (int);

int main() {return 0;}
</code>

# g++ Test1.cpp
Test1.cpp:1: error: expected '')'' before ''*'' token

Why?
Thanks

推荐答案

__stdcall是Microsoft特定的,因此不会成为gcc/g ++编译器接受的标准语言的一部分.
__stdcall is Microsoft specific so will not be part of the standard language accepted by the gcc/g++ compiler.


是否有类似的关键字来声明调用约定?
Is there a similar keyword to declare calling convention?


如果您使用的是gcc的MinGW端口,则可能是一个用于调用Windows API函数的stdcall实现.但是,您必须查看gcc文档以了解其含义(或查看MingGW windows.h,并查看其如何修饰Windows API函数原型).

如果您不使用MinGW(或gcc的其他Windows端口之一),则无需使用stdcall-默认的调用约定对于您想做的任何事情都可以. >
干杯,

If you''re using the MinGW port of gcc there''s probably a stdcall implementation for calling windows API functions. However you''ll have to look in the gcc docs to find out what it is (or look in the MingGW windows.h and see how it decorates windows API function prototypes).

If you''re not using MinGW (or one of the other Windows ports of gcc) then there''s no need to use stdcall - the default calling convention is probably okay for anything you''d want to do.

Cheers,

Ash


这篇关于函数指针编译错误:"*"标记之前的预期“)"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆