Jump to content

Lars Fosdal

Administrators
  • Content Count

    3515
  • Joined

  • Last visited

  • Days Won

    115

Posts posted by Lars Fosdal


  1. You can also define symbols in an environment variable, but then they apply to ALL projects you compile.
    dcc_define=Test;MagicSymbol;SomeOtherDefine
    dcc_define being the magic environment variable name which defines the symbols.

    Example:

    image.thumb.png.9240a9e7d1aaf03fa2af26fd8126d933.png


    This one defines "foslar" - so that I can include code that I am working on but which doesn't compile in the project and commit/push to git without breaking the build server or messing up for other users.
     

    {$ifdef foslar}
    procedure DoSomething
    begi
      What was I thinking?
    {$endif}

     


  2. I have a 5K 40" Lenovo, that can be split into two "virtual" displays.  I can set up different resolutions and scalings on those when I need to test HighDPI. 
    Generally speaking, the test results are so disheartening that I still stick with 100% scaling in the OS, and use BDS in DPI-Unaware mode.


  3. Generally speaking I prefer offloading background tasks to a threadpool in-queue. The threadpool messages the main thread when the work is done. The main thread then retrieves the response from the threadpool out-queue.(i.e. mailbox principle).

    If there are multiple parallell tasks (i.e. a job), the main thread will need to know that, and whenever a thread completes, check if it fullfill the needs of the job and then fire off whatever should happen after the job is complete.

     

    There really is no single best way to deal with background processing - except ensuring that the main thread is not blocked.


  4. 24 minutes ago, Uwe Raabe said:

    Try with external MSBuild in the project options and select x64 as preferred architecture. Key is to use the 64-bit compiler versions from the bin64 folder. The target platform is almost irrelevant. Only bcc64x got an update with the April patch.

    Yeah, THAT surfaced the dreaded error

    [dcc64 Error] NonNullableConstraint.dpr(41): Type parameter 'T' must be a non-nullable value type

    Half-baked patches are no fun. 

    Edit - Also noticed that the Error ID is lost when using MSBuild.

     


  5. @Anders Melander

    I just tried my example code which failed before the April patch in the 64-bit IDE, targeting 64-bit Windows.
    It no longer stops compiling.

    program NonNullableConstraint;
    
    {$APPTYPE CONSOLE}
    
    {$R *.res}
    
    uses
      System.SysUtils;
    
    type
      TMyClass = class
        function Select<T:Record>(const selector: string):TArray<T>;
      end;
    
      TNotifcationRow = record
      const
        Query = 'SELECT * FROM v_server_notifications';
      public
        Id: Integer;
        Name: String;
        Data: String;
        ByWho: String;
        CreatedWhen: TDateTime;
        function DataAsId: Integer;
      end;
      TServerNotificationArray = TArray<TNotifcationRow>;
    
    { TMyClass }
    
    function TMyClass.Select<T>(const selector: string): TArray<T>;
    begin
    
    end;
    
    procedure Test;
    var
      MyClass: TMyClass;
      Res: TServerNotificationArray;
    begin
      MyClass := TMyClass.Create;
      Res := MyClass.Select<TNotifcationRow>('foo'); // <- E2512 Type parameter 'T' must be a non-nullable value type
    end;
    
    { TNotifcationRow }
    
    function TNotifcationRow.DataAsId: Integer;
    begin
      Result := 0;
    end;
    
    begin
      try
        Test;
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
    end.

     

    • Thanks 1
×