3

In C++Builder XE2 the IDE will place this line of code in the header file associated with TMyForm immediately after the TMyForm class. I'm certain this relates to the the fact that all of the properties TMyForm are defined in MyForm.dfm and need to be linked into the executable somehow, but I can't find any reference to it in the documentation or online. Googling for "extern PACKAGE" just yields a lot of code samples that contain the phrase.

Strangely, commenting it out doesn't seem to have any effect. I even deleted the .res file and did a rebuild and the form works fine without it. Which seems to negate my assumption above.

4

1 回答 1

8

extern TMyForm *MyForm用于声明一个全局变量(它实际上驻留在您的 Form 的 .cpp 文件中)。TForm如果该变量配置为在应用程序启动时自动加载,或者您在自己的代码中手动分配它,则此变量在运行时指向您的对象。

PACKAGE是一个扩展为 的宏__declspec(package),如果您选择在包中使用它,它会将类标记为可在包中编译。

于 2013-05-02T20:45:12.787 回答