函数指针和调用约定

时间:2011-01-28 16:05:34

标签: c function

float __stdcall (*pFunc)(float a, float b) = (float (__stdcall *)(float,float))0x411280;

如何使用调用约定声明函数指针?上面给出了一个错误。

3 个答案:

答案 0 :(得分:37)

诀窍是将__stdcall放在括号内,如下所示:

float (__stdcall *pFunc)(float a, float b) = (float (__stdcall *)(float,float))0x411280;

当然,建议您使用typedef,但同样的技巧适用:

typedef float (__stdcall *FuncType)(float a, float b);

答案 1 :(得分:1)

WHERE是编译器最接受的形式。一些编译器接受lag as ( select *, LAG(tier) OVER (PARTITION BY account_id ORDER BY date ASC) AS previous_plan , LAG(date) OVER (PARTITION BY account_id ORDER BY date ASC) AS previous_plan_date from data ) SELECT * FROM lag where (current_plan = 'free' and previous_plan in ('monthly', 'yearly')) answerQuestions() { if (this.shift.getEarly() && (this.shift.getTimeToStart().asHours() > environment.alertTimes.answerQuestions)) { var timeTo = this.durationFormatPipe.transform(this.shift.getStart()); var message = 'Your shift starts ' + timeTo + ', are you sure you want to answer questions now?'; setTimeout(() => { this.alertService.confirmOrCancelAlert('You are early!', message, () => { this.doAnswerQuestions(); }); }, 50); } else { this.doAnswerQuestions(); } } 甚至int (__cdecl **func)()。 Clang接受所有3种形式并将其正确解释为类型int __cdecl (**func)(int)

在clang上引入int (**__cdecl func)(int)指针也不会改变图片,并且只要const在指针之后即可接受任何排列

int (*__cdecl *func)(int)

答案 2 :(得分:0)

__fastcall是优化的(最快的调用约定),但未用于未知原因

尝试:

int (__fastcall *myfunction)(int,float);