What is a Delphi DCU file?

后端 未结 3 532
庸人自扰
庸人自扰 2021-01-17 08:39

What is a Delphi DCU file?

I believe it stands for \"Delphi Compiled Unit\". Am I correct in assuming it contains object code, and therefore corresponds to an \".o\"

3条回答
  •  天命终不由人
    2021-01-17 09:20

    In addition to David Schwartz's answer, there is one case when a dcu actually is quite different from typical obj files generated in other languages: Generic type definitions. If a generic type is defined in a Delphi Unit, the compiler compiles this code into a syntax tree representation rather than to machine code. This syntax tree representation then is stored in the dcu file. When the generic type then is used and instantiated in another unit, the compiler will use this representation and "merge" it with the syntax tree of the unit using the generic type. You could think of this being somewhat analogues to method inlining. This, btw is also the reason why a unit that makes heavy use of generics takes much longer to compile, although the generic types are "linked in" from a dcu file.

提交回复
热议问题