2012-10-25 33 views
3

我將代碼從XE2移動到Delphi XE3,但它應該在兩者中進行編譯。我注意到有些單位將'System.Actions'自動添加到USES子句中。錯誤:F1026文件未找到:'System.Actions.dcu'從XE3切換回Delphi XE2

F1026找不到文件:與返回XE2時,這進而導致出現的錯誤「System.Actions.dcu」(單位範圍「系統」是指Win64中,OSX32,只有Win32)

我從來沒有真正正確理解單位範圍。有沒有正確的解決方案來解決這個問題,而不是在編譯器版本{$ IFDEF}中包裝的東西?

感謝

回答

10

有一個在XE2沒有Actions單元。這是XE3中的新功能,作爲將Actions支持帶入FireMonkey的重構工作的一部分。這證明:

What's New in Delphi and C++Builder XE3

Actions: FireMonkey now supports actions and action lists, two features that were previously supported only in VCL:

Important: Every FireMonkey or VCL application that uses actions must specify the System.Actions and System.Classes units in the uses section.

Changes in Implementation of VCL Actions

The System.Actions unit is created in the RTL package. Classes from the Vcl.ActnList unit that provide framework-independent action features are moved into this unit. Classes in System.Actions extend the most fundamental behavior of action features introduced in the TBasicAction and TBasicActionLink classes.

Important: As a result of these changes, you need to add the System.Classes and System.Actions units into the uses section.

Implementation of Actions in FireMonkey and VCL

FireMonkey (FMX)

The framework-independent implementation is common to FireMonkey and VCL: This basic actions functionality is extended in the new System.Actions RTL unit.

VCL

Framework-independent action features that were implemented in the Vcl.ActnList unit in previous RAD Studio releases are now in the new System.Actions unit in the RTL (common to VCL and FireMonkey).

Important: As a result of these changes, you need to add the System.Actions unit to the uses section (or #includes) in your VCL applications that use actions.

你將不得不或者如果你沒有實際使用的行爲刪除對Actions參考在你的 代碼,否則{$IFDEF}出來。

10

Remy說的非常正確,但是可能有一種更簡單的方法可以使您的代碼在XE2和XE3中都能正常工作。只需將一個單元別名從System.Actions添加到Vcl.ActnList即可。

將此項添加到您的項目選項中,在Delphi Compiler頁面上。您需要添加以下內容:

System.Actions=Vcl.ActnList 

請注意,如果您需要在這兩個XE2以及XE3編譯使用相同的.dproj文件,那麼你的運氣了。該單元別名設置將停止XE3下的程序編譯。但是,如果您對XE2和XE3有不同的.dproj文件,那麼這將允許您在兩者中使用相同的源文件。或者,如果您只需要在命令行編譯XE2,則可以在此處添加此單元別名。我無法分辨這是否會對您有所幫助,但我知道單元別名功能在過去多次幫助我脫離類似現場。

2

如果您有一個項目文件,您仍然可以通過項目路徑目錄中的「dummy」System.Actions.pas文件解決問題: 此文件將在XE2下進行。 XE3編譯器將在IDE/lib目錄中找到他的System.Actions.dcu。

無論如何:在正常情況下,您應該使用不同的項目文件 - 然後推薦使用單位別名的解決方案。

僞System.Actions.pas可能看起來像:

unit System.Actions; 
    (* 
    XE2 compatibility unit: since XE3 unit System.Actions will be inserted into every 
    interface in units which use actions. 
    compilerswitch in [uses] is ignored by IDE - so this solution enable successful 
    compilation in XE2 with same project file than XE3 
    *) 
    interface 

    implementation 

    end. 
+0

好主意,謝謝。 –

+0

@BitBumper當這個「dummy」System.Actions.pas在項目路徑目錄中時,如何使XE3(或更高版本)的編譯器在IDE lib目錄中找到他的System.Actions.dcu?看起來XE3(或更高版本)無論如何都會首先找到這個虛擬文件。 – SOUser