delphi - Delphi函数名在Obj文件中的作用

标签 delphi delphi-7

Delphi在编译pas文件时函数名的作用是什么?

例如下面的代码

unit Hellopas;
interface
function HelloFromPas():Integer; stdcall; 

会推导出这个函数名@Hellopas@HelloFromPas$qqsv

那么 Delphi 的角色是什么?

最佳答案

这是一个修饰或损坏的名称。该名称对函数及其参数的完整范围进行编码。包含单位名称是因为它是完全限定名称的一部分。参数、返回值和调用约定也被编码,这里为qqsv

Wikipedia解释了像这样进行重整的必要性:

In compiler construction, name mangling (also called name decoration) is a technique used to solve various problems caused by the need to resolve unique names for programming entities in many modern programming languages.

It provides a way of encoding additional information in the name of a function, structure, class or another datatype in order to pass more semantic information from the compilers to linkers.

The need arises where the language allows different entities to be named with the same identifier as long as they occupy a different namespace (where a namespace is typically defined by a module, class, or explicit namespace directive) or have different signatures (such as function overloading).

Any object code produced by compilers is usually linked with other pieces of object code (produced by the same or another compiler) by a type of program called a linker. The linker needs a great deal of information on each program entity. For example, to correctly link a function it needs its name, the number of arguments and their types, and so on.

关于delphi - Delphi函数名在Obj文件中的作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33585920/

相关文章:

delphi - Delphi "with"关键字是一个不好的做法吗?

delphi - 为什么在 FormCreate 中会失败,但在 FormShow 中却工作正常?

delphi - 中断 HTTP GET 操作

delphi - 将旧的 Delphi 7 代码迁移到 Delphi XE - 未找到 QForms.dcu

Delphi 7从备注行中删除一些字符

delphi - 当组件添加到窗体时,Delphi 单元如何自动添加?

delphi - 如何使用注释对字符串列表进行排序

德尔福,GR32 + PngObject : converting to Bitmap32 doesn't work as expected

delphi - 您通过哪些登录桌面应用程序来提高稳定性?

delphi - 我怎么知道是否创建了用户定义组件?