Please explain package use

荒凉一梦 提交于 2019-12-08 06:40:10

问题


Please explain package use (in short sentences with small words (for Dummies)).

I just moved from D7 to XE2 and packages seem much more prevelant, and I seem to need to qualify a lot more things.

In D7 I would say uses windows and now I must say uses winapi.windows.

I find that when I call MessageDlg() I can't pass in mtError, I need to qualify it.

Before I go too far down the wrong road - what's the simple solution?

Can I somehow continue to use my old code with package names which I suspect are terminal (that is, for packages A.B.C I have auses C clause).

Can I add one statement somewhere to do this? Or configure the project.

Sorry to sound so dumb :-(


回答1:


These are called unit scopes. Because of the new FireMonkey libraries, and the cross-platform support, it's required that you declare which unit you're referring to for types and function declarations.

You can set defaults using Project->Options->Compiler->Unit Scope Names. This is documented as well.




回答2:


Package use is no different in XE2 than in earlier versions. What is different is that all of Embarcadero's unit names are now prefixed with new Unit Scope Names ("System", "Vcl", "Winapi", etc) to help designate which units belong to the RTL, the VCL, FireMonkey, specific platforms, etc.

You can update your code to fully qualify everything now, if you want to, but you do not have to. You can instead specify the particular scope names in the "Unit Scope Names" setting of the Project Options instead, then no code changes are needed (other than the usual changes when migrating from one version to another).



来源:https://stackoverflow.com/questions/8775578/please-explain-package-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!