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/