3
votes

I'm moving my code to Delphi XE3 from XE2, but it should compile in both. I notice that some units get 'System.Actions' auto added to the USES clause. This then causes an error when returning to XE2 with:

F1026 File not found: 'System.Actions.dcu' (unit scope "System" indicates Win64, OSX32, Win32 only)

I've never really understood unit scope properly. Is there a correct solution to resolve this rather than wrapping stuff within compiler version {$IFDEF}'s?

Thanks

3

3 Answers

10
votes

There is no Actions unit in XE2. It is new in XE3, as part of refactoring work to bring Actions support into FireMonkey. This is documented:

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.

You will have to either remove the reference to Actions if you are not actually using actions in your code, or else {$IFDEF} it out.

10
votes

What Remy said is quite correct, but there may be an easier way to make your code work in both XE2 and XE3. Simply add a unit alias from System.Actions to Vcl.ActnList.

Add this in your project options, on the Delphi Compiler page. You need to add the following:

System.Actions=Vcl.ActnList

Note that if you need to compile in both XE2 and XE3 using the same .dproj file then you are out of luck. That unit alias setting will stop the program compiling under XE3. However, if you have have different .dproj files for XE2 and XE3, then this will allow you to use the same source in both. Or, if you only need to compile for XE2 at the command line, then you could add this unit alias there. I can't tell whether or not this will help you, but I know that the unit alias feature has helped me out of a similar spot on more than one occasion in the past.

2
votes

If you have ONE project file you still can solve the problem with a "dummy" System.Actions.pas file in your project path directory: This file will be taken under XE2. The XE3 compiler will find his System.Actions.dcu in the IDE /lib directory.

Anyway: In normal cases you should use different project files - then the solution with the unit alias is recommended.

The dummy System.Actions.pas could look like:

    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.