Cannot Compile (Delphi XE)

Questions and answers on how to use DOCXReadWrite
Post Reply
Vinski
Posts: 12
Joined: Thu Dec 16, 2021 7:41 am

Cannot Compile (Delphi XE)

Post by Vinski »

Hello,

I just upgraded to Version 2 of DOCXReadWrite, but now the program won't compile.
I get an Error in the following line, which is part of the unit "AXWSynCrypto"

Code: Select all

{$ifdef USEAESNI} (cfAESNI in CpuFeatures) or {$endif}
Delphi says "Undeclared identifier cfAESNI"
and "Undeclared identifier CpuFeatures"

Did I mess up Installation?
If yes, how do I install correctly?
If no, what can I do to solve this problem?
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Cannot Compile (Delphi XE)

Post by larsa »

Hello

I don't recognize that code line. Can you please show some more lines.
Lars Arvidsson, Axolot Data
Vinski
Posts: 12
Joined: Thu Dec 16, 2021 7:41 am

Re: Cannot Compile (Delphi XE)

Post by Vinski »

Code: Select all

unit AXWSynCrypto;

Code: Select all

{ we use direct Windows threads, since we don't need any exception handling
  nor memory usage inside the Thread handler
   -> avoid classes.TThread and system.BeginThread() use
   -> application is still "officialy" mono-threaded (i.e. IsMultiThread=false),
     for faster System.pas and FastMM4 (no locking)
   -> code is even shorter then original one using TThread }
function ThreadWrapper(var P: TThreadParams): Integer; stdcall;
begin
  SetCurrentThreadName('AES #%',[P.BlockIndex]);
  with P do
    AES.DoBlocks(bIn,bOut,bIn,bOut,BlockCount,Encrypt);
  ExitThread(0);
  result := 0; // make the compiler happy, but won't never be called
end;

procedure TAES.DoBlocksThread(var bIn, bOut: PAESBlock; Count: integer; doEncrypt: boolean);
var Thread: array[0..3] of TThreadParams; // faster than dynamic array
    Handle: array[0..3] of THandle; // high(Thread) is not compiled by XE2
    nThread, i, nOne: integer;
    pIn, pOut: PAESBlock;
begin
  if Count=0 then exit;
  if {$ifdef USEPADLOCK} padlock_available or {$endif}
     {$ifdef USEAESNI} (cfAESNI in CpuFeatures) or {$endif}
    (SystemInfo.dwNumberOfProcessors<=1) or // (DebugHook<>0) or
    (Count<((512*1024) div AESBlockSize)) then begin // not needed below 512 KB
    DoBlocks(bIn,bOut,bIn,bOut,Count,doEncrypt);
    exit;
  end;
  nThread := SystemInfo.dwNumberOfProcessors;
  if nThread>length(Thread) then // a quad-core is enough ;)
    nThread := length(Thread);
  nOne := Count div nThread;
  pIn := bIn;
  pOut := bOut;
  for i := 0 to nThread-1 do
  with Thread[i] do begin // create threads parameters
    bIn := pIn;
    bOut := pOut;
    BlockCount := nOne;
    BlockIndex := i+1;
    Encrypt := doEncrypt;
    AES := self; // local copy of the AES context for every thread
    Handle[i] := CreateThread(nil,0,@ThreadWrapper,@Thread[i],0,ID);
    inc(pIn,nOne);
    inc(pOut,nOne);
    dec(Count,nOne);
  end;
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Cannot Compile (Delphi XE)

Post by larsa »

Hello

I have posted a new update now. Please download it.
Lars Arvidsson, Axolot Data
Vinski
Posts: 12
Joined: Thu Dec 16, 2021 7:41 am

Re: Cannot Compile (Delphi XE)

Post by Vinski »

Hello,

I installed the update, but it seems, that the Unit

Code: Select all

unit AXWSynCrypto;
has not been changed.
Hence the Problem persists and
"cfAESNI" as well as "CpuFeatures"
remain undefined.

I use Delphi XE.
Post Reply