送分的小问题

Greg_han 2008-11-28 03:51:45
学习C++ Builder6.0 一段时间了
没有留心 __published 和 _fastcall 是什么东东,请解释。如:

__published:
.......

int __fastcall A();
void __fastcall B();
...全文
89 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jxw1987628 2008-11-28
  • 打赏
  • 举报
回复
//同意 2楼的意见
jaffy 2008-11-28
  • 打赏
  • 举报
回复
BCB帮助下有的,接分
xfblue 2008-11-28
  • 打赏
  • 举报
回复
同在学习C++ builder6.0中
springworker 2008-11-28
  • 打赏
  • 举报
回复
也来学习!
shadowstar 2008-11-28
  • 打赏
  • 举报
回复
__published 公布

在该段时声明的类成员才能拥有运行期类型信息(RTTI),才能被属性编辑器处理。
编写组件时把要公布的属性放到__published段。
在编写程序的时候,事件函数都被声明在__published段,否则将不能在属性编辑器内直接选择。(如:Button1Click)

__fastcall 快速调用

Delphi默认的函数调用方式,指定了调用函数时堆栈和寄存器的使用方式。
VCL是由Delphi实现的,函数都是__fastcall调用方式。
C程序默认的调用方式是__cdecl,__fastcall使用寄存器较多,会更快一些。
自己的程序不加__fastcall也可以。
yumikoo 2008-11-28
  • 打赏
  • 举报
回复
__published

The __published keyword specifies that properties in that section are displayed in the Object Inspector, if the class is on the Component palette. Only classes derived from TObject can have __published sections.
The visibility rules for published members are identical to those of public members. The only difference between published and public members is that Object Pascal-style runtime type information (RTTI) is generated for data members and properties declared in a __published section. RTTI enables an application to dynamically query the data members, member functions, and properties of an otherwise unknown class type.

Note: No constructors or destructors are allowed in a __published section. Properties, Pascal intrinsic or VCL derived data-members, member functions, and closures are allowed in a __published section. Fields defined in a __published section must be of a class type. Properties defined in a __published section cannot be array properties. The type of a property defined in a __published section must be an ordinal type, a real type, a string type, a small set type, a class type, or a method pointer type.


_fastcall, __fastcall

Category

Modifiers, C++Builder keyword extensions

Syntax

return-value _fastcall function-name(parm-list)

return-value __fastcall function-name(parm-list)

Description

Use the __fastcall modifier to declare functions that expect parameters to be passed in registers. The first three parameters are passed (from left to right) in EAX, EDX, and ECX, if they fit in the register. The registers are not used if the parameter is a floating-point or struct type.

All form class member functions must use the __fastcall convention.

The compiler treats this calling convention as a new language specifier, along the lines of _cdecl and _pascal

Functions declared using _cdecl or _pascal cannot also have the _fastcall modifiers because they use the stack to pass parameters. Likewise, the __fastcall modifier cannot be used together with _export.

The compiler prefixes the __fastcall function name with an at-sign ("@"). This prefix applies to both unmangled C function names and to mangled C++ function names.

For Microsoft VC++ style __fastcall implementation, see __msfastcall and __msreturn.

Note: The __fastcall modifier is subject to name mangling. See the description of the -VC option.


int fun()和void一个是返回Int值一个是无返回值

这些问题以后自己看帮助文件找或者Google找,不要养成轻易问人的习惯。

13,826

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧