Sign in Join
Wiki copytemporary

Revision 1 of 2, by Maxim on 1-27-2024. The page as it is now.

FPC New Features Trunk

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

Compiler

fpcres can compile RC files

Language

Support for "volatile" intrinsic

Support for "noinline" modifier

Support for multiple active helpers per type

Support for custom attributes

pascal
program tcustomattr;

{$mode objfpc}{$H+}
{$modeswitch prefixedattributes}

type
  TMyAttribute = class(TCustomAttribute)
    constructor Create;
    constructor Create(aArg: String);
    constructor Create(aArg: TGUID);
    constructor Create(aArg: LongInt);
  end;

  {$M+}
  [TMyAttribute]
  TTestClass = class
  private
    fTest: LongInt;
  published
    [TMyAttribute('Test')]
    property Test: LongInt read fTest;
  end;
  {$M-}

  [TMyAttribute(1234)]
  [TMy('Hello World')]
  TTestEnum = (
    teOne,
    teTwo
  );

  [TMyAttribute(IInterface), TMy(42)]
  TLongInt = type LongInt;

constructor TMyAttribute.Create;
begin
end;

constructor TMyAttribute.Create(aArg: String);
begin
end;

constructor TMyAttribute.Create(aArg: LongInt);
begin
end;

constructor TMyAttribute.Create(aArg: TGUID);
begin
end;

begin

end.

Support for constant parameters in generics

Support for "IsConstValue" intrinsic

Copy supports Open Array parameters

pascal
procedure Test(aArg: array of LongInt);
var
  arr: array of LongInt;
begin
  arr := Copy(aArg, 3, 5);
end;

Array constructors for static arrays

"Align" modifier support for record definitions

Support for binary literals in Delphi mode

pascal
{$mode Delphi}
var
  b: byte;
begin
  b:=%11001001;
end.

Support for Digit Separator

pascal
{$mode Delphi}
var
  i: Integer;
  r: Real;
begin
  i := %1001_1001;
  i := &121_102;
  i := 1_123_123;
  i := $1_123_123;  
  r := 1_123_123.000_000;
  r := 1_123_123.000_000e1_2;
end.

Support for forward declarations of generic types

pascal
{$mode objfpc}
type
  generic TTest<T> = class;
  generic TFoo<T: class> = class;
  generic TBar<const N: LongInt> = class;

  TSomething = class
    fTest: specialize TTest<LongInt>;
    fFoo: specialize TFoo<TObject>;
    fBar: specialize TBar<42>;
  end;

  generic TTest<T> = class end;
  generic TFoo<T: class> = class end;
  generic TBar<const N: LongInt> = class end;

begin
end.

Support for Function References and Anonymous Functions

Descendant type helpers can extend type aliases

Support for Unicode RTL

Support for Extended RTTI

Units

DaemonApp

Additional control codes on Windows

Classes

Naming of Threads

Objects

TRawByteStringCollection
TUnicodeStringCollection
TStream methods for reading and writing RawByteString and UnicodeString

FUNCTION TStream.ReadRawByteString: RawByteString;
FUNCTION TStream.ReadUnicodeString: UnicodeString;
PROCEDURE TStream.WriteRawByteString (Const S: RawByteString);
PROCEDURE TStream.WriteUnicodeString (Const S: UnicodeString);

RawByteStrings are written to the stream as a 16-bit code page, followed by 32-bit length, followed by the string contents. UnicodeStrings are written as a 32-bit length (the number of 16-bit UTF-16 code units needed to encode the string), followed by the string itself in UTF-16.

Free Vision

Unicode support

Video

Unicode output support

Keyboard

Unicode keyboard input support

 TEnhancedKeyEvent = record
   VirtualKeyCode: Word;    { device-independent identifier of the key }
   VirtualScanCode: Word;   { device-dependent value, generated by the keyboard }
   UnicodeChar: WideChar;   { the translated Unicode character }
   AsciiChar: Char;         { the translated ASCII character }
   ShiftState: TEnhancedShiftState;
   Flags: Byte;
 end;

TEnhancedShiftState is a set of TEnhancedShiftStateElement, which is defined as:

 TEnhancedShiftStateElement = (
   essShift,             { either Left or Right Shift is pressed }
   essLeftShift,
   essRightShift,
   essCtrl,              { either Left or Right Ctrl is pressed }
   essLeftCtrl,
   essRightCtrl,
   essAlt,               { either Left or Right Alt is pressed, but *not* AltGr }
   essLeftAlt,
   essRightAlt,          { only on keyboard layouts, without AltGr }
   essAltGr,             { only on keyboard layouts, with AltGr instead of Right Alt }
   essCapsLockPressed,
   essCapsLockOn,
   essNumLockPressed,
   essNumLockOn,
   essScrollLockPressed,
   essScrollLockOn
 );

A special value NilEnhancedKeyEvent is used to indicate no key event available in the result of PollEnhancedKeyEvent:

 { The Nil value for the enhanced key event }
 NilEnhancedKeyEvent: TEnhancedKeyEvent = (
   VirtualKeyCode: 0;
   VirtualScanCode: 0;
   UnicodeChar: #0;
   AsciiChar: #0;
   ShiftState: [];
   Flags: 0;
 );

Darwin/macOS platforms

Support for symbolicating Dwarf backtraces

New compiler targets

Support for code generation through LLVM

Support for address sanitizer (asan) through LLVM

Support for the Z80

Support for the WebAssembly target


From the Free Pascal wiki, page "FPC New Features Trunk", as it stood on 2024-01-27 after a change by Maxim, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.