FPC New Features Trunk

From Free Pascal wiki
Jump to: navigation, 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.

A list of changes that may break existing code can be found here.

All systems

Language

Support for interfacing with C blocks functionality

  • Overview: Support has been added for interfacing with Apple's blocks C-extension.
  • Notes:
    • As C blocks are very similar to anonymous methods in Delphi, we use a similar syntax to declare block types (with an added cdecl to indicate the C nature). Note that the syntax to define the code executed in a block (inline, like with anonymous methods in Delphi, or in a separately defined function/method) and the functionality of a block (the ability to capture context and code to execute it at an arbitrary point in the future) are two separate things. At this time (r29594), only the code from a global function/procedure or from an Object Pascal instance/class method can be executed within the context of a block. In the future, support will be added for nested functions and later probably also for code that is defined inline, like in Delphi.
    • This functionality is currently only supported by FPC on Mac OS X 10.7 and later, and on iOS 4.0 and later. The reason it doesn't work on Mac OS X 10.6, is that we require functionality that was added to the blocks runtime in later versions.
    • The blocks functionality can be activated on supported platforms via {$modeswitch cblocks}
  • More information:
  • svn: r29517, r29594

Support for Default Namespaces

  • Overview: Namespaces can be supplied to the compiler to be prefixed to units that would otherwise not be found
  • Description:
    • Use the new -FN<x> parameter to add a default namespace <x> to the list of default namespaces. If a unit name can not be found as-is then it will be searched for using all provided default namespaces as prefix (separated by a ".") until it is found or the list of namespaces is exhausted.
    • The default namespaces can also be used as prefixes for identifiers outside the uses section.
  • More information: announcement mail at http://lists.freepascal.org/pipermail/fpc-pascal/2018-May/053768.html
  • svn: r38911 - r38922

Dynamic Arrays supported by Insert()

  • Overview: The Insert() intrinsic can be used to insert arrays and elements into an existing dynamic array.
  • Notes:
    • The element to be inserted can be either of the following:
      • dynamic array of the same type
      • static array of the same type
      • a single element of the array's element type
    • The insertion index is zero based
    • If the dynamic array to be modified is empty it will simply contain the new data afterwards
    • If the index is larger than the current highest index of the array then the new data is appended at the end
    • If the index is negative then the new data will be appended at the start of the array
    • This feature is Delphi compatible with the exception of inserting static arrays which is not supported by Delphi
  • More information: announcement mail at http://lists.freepascal.org/pipermail/fpc-pascal/2018-May/053891.html

Dynamic Arrays supported by Delete()

  • Overview: The Delete() intrinsic can be used to remove a sub range from an existing dynamic array.
  • Notes:
    • The start index is zero based
    • The resulting range of Index and Count will be capped at the dynamic array's boundaries (namely 0 and the highest element); this may mean that in an extreme case no element is removed as the range is outside of the array's
    • This feature is Delphi compatible
  • More information: announcement mail at http://lists.freepascal.org/pipermail/fpc-pascal/2018-May/053891.html

Dynamic Arrays supported by Concat()

  • Overview: The Concat() intrinsic can be used to concatenate two or more dynamic arrays together.
  • Notes:
    • The resulting array will look as if all array elements had been added manually to the new array in order
    • Empty arrays don't contribute to the new array
    • This feature is Delphi compatible
  • More information: announcement mail at http://lists.freepascal.org/pipermail/fpc-pascal/2018-May/053891.html

Dynamic Arrays have built in + operator support

  • Overview: The + operator can be used to concatenate two or more dynamic arrays together.
  • Notes:
    • Requires new modeswitch ArrayOperators (enabled by default in Delphi modes)
    • The resulting array will look as if all array elements had been added manually to the new array in order
    • Empty arrays don't contribute to the new array
    • This feature is Delphi compatible
  • More information: announcement mail at http://lists.freepascal.org/pipermail/fpc-pascal/2018-May/053891.html

Dynamic Array constants and variable initialization

  • Overview: Dynamic arrays constants are now possible just as well as initializing dynamic array variables during their declaration. In both cases the same syntax as for static arrays is used.
  • Notes:
    • Adheres to the $J switch regarding writable constants, both for the variable itself as well as its content
    • Static and dynamic array constants can be nested
    • Delphi compatibility:
      • In Delphi modes the syntax is […] instead of (…)
      • Static array constants can not be used inside dynamic array constants
      • Delphi does not adhere to the $J switch for the array's contents
  • More information: announcement mail at http://lists.freepascal.org/pipermail/fpc-pascal/2018-May/053891.html

Dynamic Arrays constructors

More settings supported by $Push/$Pop

  • Overview: The directives $Push and $Pop now also handle the directives $MinEnumSize, $PackSet and $PackRecords.

Support for threadvar sections inside class and record types

  • Overview: Class and record types can now contain a class threadvar section that allows for the addition of scoped threadvar variables.
  • Notes:
    • This feature is Delphi compatible
    • Not including the class specifier is considered an error
  • svn: 39285 - 39289

IDE

GDB/MI support

  • Overview: GDB/MI support has been added to the text mode IDE.
  • Notes:
    • It is enabled default, but can be disabled by building FPC with make NOGDBMI=1
    • The old and deprecated libgdb.a support is still there for platforms that do not have a modern GDB port (or e.g. don't support true multitasking, like go32v2).
    • When debugging a console application in Windows in GDB/MI mode, the debugged program is always run in a separate console. This is due to a limitation of the Windows GDB port.
  • svn: r30573

(Mac) OS X/iOS

New iosxwstr unit

  • Overview: The new unit called iosxwstr can be used to install a widestring manager on (Mac) OS X and iOS.
  • Notes: The cwstring unit fulfils the same purpose, but is no longer able to provide full functionality on iOS 7 and newer due to Apple no longer shipping the locale and codepage information this unit depends on. The iosxwstr unit gets its locale information for upper/lowercase conversions from the System Preferences. Adding both cwstring and iosxwstr to the uses clause will cause the second in line to override the settings from the first one.
  • More information: Adding this unit to the uses clause is enough to use its functionality.
  • svn: r29828

i8086-msdos

Huge memory model

  • Overview: Support has been added for the i8086 huge memory model.
  • Notes: The huge memory model (compared to the large memory model) removes the 64kb limitation of static data for the whole program. However, there's still a 64kb limit for the static data of a single unit.
  • More information: Huge memory model
  • svn: r31518

Internal assembler (object writer)

  • Overview: There's an internal assembler/object writer implemented for the i8086-msdos platform. It replaces NASM and the WLIB tool.
  • Notes: NASM is still required for building an i8086-msdos snapshot, because of the msdos startup code in the rtl. However, WLIB (from Open Watcom) is no longer required, so you can now build a fully functional smartlinked i8086-msdos snapshot from a platform that doesn't have the Open Watcom tools (such as DJGPP or Mac OS X).
  • svn: r30809

Internal linker

  • Overview: There's an internal linker implemented for the i8086-msdos platform. It replaces WLINK from Open Watcom.
  • Notes: Together with the internal assembler, the internal linker removes the dependency on Open Watcom tools. NASM is still required for building an i8086-msdos snapshot, because of the msdos startup code in the rtl.
  • svn: r31425

FarAddr internal function

  • Overview: There's a new i8086-specific internal function, similar to Addr(), called FarAddr(), which always returns a far pointer to the address of its argument.
  • Notes: The built-in Addr() function and the @ operator return a pointer type (near or far), that depends on the memory model. When interfacing with DOS, BIOS and other 16-bit APIs, it is sometimes useful to be able to obtain a far pointer to a pascal variable or procedure/function, regardless of the selected memory model. Previously, you would have to use ifdefs, or do something like Ptr(Seg(x), Ofs(x)). Now, this can be replaced with the much nicer FarAddr(x).
  • svn: r37629

Near and far procedure variables

  • Overview: Support has been added for procedure variables with an explicitly specified near or far call model.
  • Notes: By default, procedure variables follow the default call model of the current memory model - near in the tiny, small and compact memory models; far in the medium, large and huge models. However, now you can specify an explicit near or far call model, regardless of the default for the current memory model. Note that near and far procedure variables are not compatible with each other. Syntax is really simple:
type
  TFarProc = procedure(a, b: Integer); far;
  TNearProc = procedure(a, b: Integer); near;

Near procedure variables are 2 bytes long, so they contain only an offset. They are invoked with a near call instruction. Far procedure variables are 4 bytes long (16-bit offset + 16-bit offset) and are invoked with a far call. Note that you cannot simply convert a near procedure to a far procedure, by just filling in the segment part, because the call model is also different between near and far procedures. A far call instruction pushes a 4-byte far (segment:offset) return address and the function must terminate with a far return instruction - retf. A near call instruction pushes only a 2-byte offset on the stack and the function must terminate with a near return instruction - retn.

  • svn: r38691

New compiler targets

Support for the AArch64 target

  • Overview: Support has been added for the AArch64 architecture. Both Darwin (iOS) and Linux supported.
  • Notes: Apple's A7 CPU (and potentially other AArch64 CPUs too) does not support raising a signal when a floating point exception occurs.
  • More information: http://lists.freepascal.org/pipermail/fpc-devel/2015-February/035397.html
  • svn: r29986 (Darwin/iOS), r30897 (Linux)

Support for the Linux/ppc64le target

  • Overview: Support has been added for the Linux/ppc64le target. This is a PowerPC64 little endian platform that uses a new ABI termed ELFv2.
  • Notes: It is not easy to build this target on a big endian Linux/ppc64 target, due to the fact that the build system does not yet contain support to deal with different ABIs/endianess.
  • More information: To cross-compile a ppc64le compiler, use CROSSOPT="-Cb- -Caelfv2". Those options don't have to be specified when compiling on a ppc64le system using a native ppcppc64, as they will be set by default for that compiler.
  • svn: r30228

Support for the i8086-win16 (16-bit Windows) target

  • Overview: Experimental support has been added for the 16-bit Windows target. It is a cross compiler only target (cross compilation is possible from e.g. Win32, Win64 or Linux).
  • Notes: Windows 3.0 or later is supported.
  • More information: Win16

New Features from other versions