FPC New Features Trunk

From Free Pascal wiki
Revision as of 19:12, 24 December 2010 by Jonas (talk | contribs) (documented ARM Thumb-2 and VFP support)
Jump to navigationJump to search

About this page

Below you can find a list of new features introduced since the previous release, along with some background information and examples.

All systems

Language changes

Better support for Delphi-compatible classes

  • Overview: Support has been added for nested types (including other classes), class variables and class-local constants.
  • Notes: Delphi-compatible.
  • More information: class_extensions_examples lists several examples that make use of these features.

Scoped enumerations

Custom deprecated messages

  • Overview: Deprecated can now be applied to virtually any syntactic element (including constants and units), and it is also possible to specify a custom deprecation message.
  • Notes: Delphi-compatible
  • More information:

<delphi> Todo: write example </delphi>

Support for Objective-Pascal dialect

  • Overview: On Mac OS X, most system frameworks are written in Objective-C. While it is possible to interface them via a procedural API, this is not very convenient. For this reason, we have created a new dialect called Objective-Pascal that enables seamless interacting with Objective-C code.
  • Notes: This new dialect is currently only supported on Darwin-based platforms (including iOS) using the Apple Objective-C runtime. Patches to add support for the GNUStep runtime are welcome.
  • More information:
    • FPC_PasCocoa explains the basic language definitions.
    • FPC_PasCocoa/Differences explains some of the differences between Objective-Pascal and on the one hand Object Pascal, and on the other hand Objective-C.

Constref parameter modifier

  • Overview: Apart from the existing var, const and out parameter modifiers, a new modifier called constref has been added. This modifier means that the compiler can assume that the parameter is constant, and that it must be passed by reference. Its most obvious usage is to translate const * parameters from C headers.
  • Notes: The main reason it was introduced was to enable writing a cross-platform interface for XPCOM, as explained on the User_Changes_Trunk page. Note that in general, it should only be used for interfacing with external code or when writing assembler routines. In other cases, letting the compiler decide how to pass the parameter is more likely to result in optimal code on most platforms.
  • More information:

<delphi> procedure test(constref l: longint); begin

 writeln('This parameter has been passed by reference, although the Pascal code does not really care about that: ',l);

end;

begin

 test(5);

end. </delphi>

ARM systems

Support for VFPv2 and VFPv3

  • Overview: Support has been added for the ARM Vector Floating Point (VFP) units versions 2 and 3. This is the floating point units that's usually included on, a.o., Cortex A8 and A9 family CPUs, and in the iOS-based devices.
  • Notes: When targeting a CPU that implements the ARMv6 or later architecture, you must also use -Cparmv6 at the same time. The reason is that saving/restoring the VFP unit's context must occur using different instructions prior to ARMv6. -Cparmv6 is enabled by default for iOS targets though, because all such devices are at least ARMv6. Additionally, FPC only supports the so-called softfp ABI for VFP: the VFP unit is used to perform the calculations, but the used calling convention to pass floating point values is the same as for soft-float.
  • More information: Activate using the -Cfvfpv2 resp. -Cfvfpv3 command line parameters.

Support for Thumb-2

  • Overview: Support has been added to generate Thumb-2 code for the ARMv7-M architecture as implemented in the Cortex-M3 family.
  • Notes: This architecture is currently only supported for no-OS targets (embedded); it does not yet work for iOS or Linux.
  • More information: Activate using the -Cparmv7m or -Cpcortexm3 command line parameters.