FPC New Features Trunk

From Free Pascal wiki
Revision as of 13:56, 5 August 2012 by Jonas (talk | contribs) (+ -Oorderfields optimization)
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. Note that since svn trunk is by definition still under development, some of the features here may still change before they end up in a release version.

All systems

Language

Delphi-like namespaces units

  • Overview: Support has been added for unit names with dots.
  • Notes: Delphi-compatible.
  • More information: Unit names with dots creates namespace symbols which always have a precedence over unit names while an identifier search.

Dynamic array constructors

  • Overview: Support has been added for constructing dynamic arrays with class-like constructors.
  • Notes: Delphi-compatible.
  • More information: Only constructor name 'CREATE' is valid for dynamic arrays.
  • Examples: SomeArrayVar := TSomeDynArrayType.Create(value1, value2)

Code generator

Class field reordering

  • Overview: The compiler can now reorder instance fields in classes in order to minimize the amount of memory wasted due to alignment gaps.
  • Notes: Since the internal memory layout of a class is opaque (except by querying the RTTI, which is updated when fields are moved around), this change should not affect any code. It may cause problems when using so-called "class crackers" in order to work around the language's type checking though.
  • More information: This optimization is currently never enabled by default at any optimization level, due to widespread use of some existing code that relies on class crackers. This will probably change in the future. You can enable the optimization by using the -Ooorderfields command line option, or by adding {$optimization orderfields} to your source file. It is possible to prevent the fields of a particular class from being reordered by adding {$push} {$optimization noorderfields} before its declaration and {$pop} after it.

Darwin/Mac OS X

Support for specifying and querying the deployment version

  • Overview: Support has been added to specify the minimum deployment target version of Mac OS X/iOS via a command line parameter, and for determining the specified deployment target version via a macro
  • More information
    • Command line parameters: -WM10.4 or -WM10.5.3 and similar for Mac OS X targets, -WP4.1 or -WP5.0.1 and similar for the iPhoneOS/iPhoneSimulator targets.
    • If no command line parameter with a deployment version is specified, the compiler will look at the MACOSX_DEPLOYMENT_TARGET resp. IPHONEOS_DEPLOYMENT_TARGET environment variables to get the deployment target version
    • if the deployment target version has not been specified using any of the previous methods, a default will be used (Mac OS X/PPC: 10.3; Mac OS X/PPC64/i386: 10.4; Mac OS X/x86-64: 10.5; iOS/iPhoneSimulator: 3.0)
    • Apart from passing the deployment target version number to the linker and linking in the appropriate startup code, the compiler will also define a symbol called MAC_OS_X_VERSION_MIN_REQUIRED resp. IPHONE_OS_VERSION_MIN_REQUIRED containing a value equivalent to the one defined by Apple's Availability.h/AvailabilityMacros.h, i.e. 1043 for Mac OS X 10.4.3, and 40102 for iPhoneOS 4.1.2. Note that this is not a constant that can be used in Pascal expressions, it's only for use by preprocessor statements.
  • Example:
procedure CGImageSourceUpdateDataProvider( isrc: CGImageSourceRef; provider: CGDataProviderRef; final: CBool ); cdecl; {$if MAC_OS_X_VERSION_MIN_REQUIRED >= 1040}external;{$else}weakexternal;{$endif}

New compiler targets

Support for the Java Virtual Machine and Dalvik targets

  • Overview: Support has been added for generating Java byte code as supported by the Java Virtual Machine and by the Dalvik (Android) virtual machine.
  • Notes: Not all language features are supported for these targets.
  • More information: The FPC JVM target

Support for the AIX target

  • Overview: Support has been added for the AIX operating system. Both PowerPC 32bit and 64bit are supported, except that at this time the resource compiler does not yet work for ppc64.
  • Notes: AIX 5.3 and later are supported.
  • More information: The FPC AIX port

See also