The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,318 other followers

Archive for the ‘Delphi’ Category

Spring4D conference materials

Posted by jpluimers on 2021/04/15

From a while ago, but still very relevant:

Materials

Timeline

twitter.com/search?q=%23Spring4D&src=typd

Read the rest of this entry »

Posted in Delphi, Development, Software Development | Leave a Comment »

“F2063 Could not compile used unit” can also mean you have a DCU file of that unit for the wrong compiler version

Posted by jpluimers on 2021/04/14

It took me a file to figure out another cause for “F2063 Could not compile used unit“, this was for a 3rd party library that had parts of the units as source files, but other parts as DCU files.

The offending unit only had DCU files, and those were in the path.

It finally occurred to me that I had a project having a DCU for the wrong Delphi version in the path.

That version check is easy to do: the 4th byte of a unit contains the CompilerVersion value with which the DCU file was compiled, and should be used with:

The first entry is for CompilerVersion value 31 (for hexadecimal value $1F) which corresponds with Delphi 10.2 Tokyo.

The last last is for CompilerVersion value 32 (for hexadecimal value $20) which corresponds with Delphi 10.3 Rio.

All versions are in Delphi version info table: C# Builder, Delphi 8 through 10.3 Rio and Appbuilder.

Related:

On the DCU and TPU file formats:

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Odd error on my Delphi research list: “E2213 Bad packaged unit format”

Posted by jpluimers on 2021/04/13

Just so I remember this did not compile in Delphi XE8 a while ago:

[dcc32 Fatal Error] DisableAlignPropertyEditor.dpr(15): E2213 Bad packaged unit format: c:\program files (x86)\embarcadero\studio\16.0\lib\Win32\release\rtl.dcp.System.SysUtils - Expected version: 29.0, Windows Unicode(x86) Found version: 32.0, Windows Ansi(x86)

Possible starting point: “E2213 Bad packaged unit format” “Expected version” “Found version” “Windows Unicode” “Windows Ansi” – Google Search

–jeroen

Posted in Delphi, Delphi XE8, Development, Software Development | Leave a Comment »

Delphi TestInsight: when supporting it, test if it is running at all. Same library has a deferer pattern.

Posted by jpluimers on 2021/04/08

Interesting idea by Cesar Romero (who has some interesting repositories at [WayBack] cesarliws (Cesar Romero) · GitHub and [WayBack] cesarliws — Bitbucket) when using TestInsight for Delphi: first test if TestInsight is running at all: [WayBack] foundation-4-delphi/Foundation.Test.Utils.pas at master · cesarliws/foundation-4-delphi · GitHub.

function IsTestInsightRunning: Boolean;
{$IFDEF TESTINSIGHT}
var
  TestInsightClient: ITestInsightClient;
begin
  TestInsightClient := TTestInsightRestClient.Create;
  TestInsightClient.StartedTesting(0);
  Result := not TestInsightClient.HasError;
end;
{$ELSE}
begin
  Result := False;
end;
{$ENDIF}

procedure RunRegisteredTests;
begin
  ReportMemoryLeaksOnShutdown := True;

{$IFDEF TESTINSIGHT}
  if IsTestInsightRunning then
    TestInsight.DUnit.RunRegisteredTests
  else
{$ENDIF}
    DUnitTestRunner.RunRegisteredTests;
end;

Another interesting bit from the same library is the deferer pattern (which is different from the promise pattern!)  in [WayBack] foundation-4-delphi/Foundation.System.pas at master · cesarliws/foundation-4-delphi · GitHub with the below code examples.

I think a better name might be DeferExecutionToEndOfScopeFor.

procedure ProcessFile (const FileName: string);
var
  File: TFile;
begin
  File: = TFile.Open (FileName);
  Defer (File.Close);
  while not File.EOF
  begin
    // ... process file
  end;
end; // Defer will be executed here [File.Close]

procedure ExecSql (const ConnectionString, Sql: string);
var
  Database: TDatabase;
  Exec: IDeferred;
  Query: TQuery;
begin
  Database: = TDatabase.Create (ConnectionString);
  Exec: = Defer (Database.Free);
  Database.Open;
  Exec.Defer (Database.Close);

  Query: = Database.Query (SQL);
  Exec.Defer (Query.Free);
  Exec.Defer (Query.Close);
  if Query.IsEmpty then
   Exit;

  while not Query.EOF
  begin
    // ... process query
  end;

  Exec.Defer (
    procedure
    begin
      Writeln ('Finished ExecSql');
    end
  );
end; // Defer will be executed here [Writeln, Query.Close, Database.Close, Database.Free]

–jeroen

Posted in Delphi, Development, Software Development, Spring4D, TestInsight | Leave a Comment »

ReturnAddressUnit to provide ReturnAddress to Delphi versions not supporting it, and prevent CallerAddr warnings for Delphi versions having ReturnAddress. See https://bitbucket.org/jeroenp/wiert.me/src/8ae6cf29ffc601fde7c1182dead740adddb13fb8/Native/Delphi/Library/RTL/ReturnAddressUnit.pas

Posted by jpluimers on 2021/04/07

From a check-in a while ago, when some Delphi versions complained about CallerAddr having been replaced by ReturnAddress and other versions not understanding ReturnAddress, but having CallerAddr.

The code in the [WayBack] gist and on [WayBack] BitBucket:

ReturnAddressUnit to provide ReturnAddress to Delphi versions not supporting it, and prevent CallerAddr warnings for Delphi versions having ReturnAddress. See https://bitbucket.org/jeroenp/wiert.me/src/…/Native/Delphi/Library/RTL/ReturnAddressUnit.pas

Basically the code maps a variable having a variable ReturnAddress that is a function reference returning a pointer to a function and redirects to CallerAddr when there is no ReturnAddress available. This is the case for anything below Delphi XE2, and avoids W1000 Symbol 'CallerAddr' is deprecated: 'Use ReturnAddress' for Delphi XE2 and up

It is an extract from [WayBack] dunit-extension/TestCaseExtension.pas at master · fabriciocolombo/dunit-extension · GitHub.

There is more interesting code in [WayBack] GitHub – fabriciocolombo/dunit-extension: Extended DUnit TestCase provides assertions to the types Date, Enumerator, Double, and other types, and a class to help run tests with output as XML, text and GUI mode and even more in [WayBack] fabriciocolombo (Fabricio Colombo) · GitHub , which are on my list of things to play with in the future.

Some more [WayBack] commits are at [WayBack] GitHub – cesarliws/dunit-extension (more on [WayBack] Cesar Romero tomorrow).

I think the code from Fabricio is inspired by [WayBack] ZeosLib/TestFrameWork.pas at master · svn2github/ZeosLib · GitHub as it uses the same HAS_BUILTIN_RETURNADDRESS define.

The code by Fabricio is smarter though.

Via: “Delphi” “CallerAddr” “ReturnAddress” – Google Search

–jeroen

Read the rest of this entry »

Posted in Delphi, Development, DUnit, Software Development | Leave a Comment »

 
<span>%d</span> bloggers like this: