Atozed Forums

Full Version: [SOLVED] Error compiling Indy 10 in FPC and patch applied
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I presume there is a little problem in Indy for FPC 3.0.4, Lazarus 1.8.4, Debian x86_64:

Compile package indylaz 10.6.2: Exit code 256, Errors: 2, Hints: 4
IdSSLOpenSSLHeaders.pas(17956,49) Hint: C arrays are passed by reference
IdSSLOpenSSLHeaders.pas(17958,64) Hint: C arrays are passed by reference
IdSSLOpenSSLHeaders.pas(17963,68) Hint: C arrays are passed by reference
IdSSLOpenSSLHeaders.pas(19230,65) Hint: Local variable "LLen" does not seem to be initialized
IdSSLOpenSSLHeaders.pas(19571,10) Error: function header doesn't match the previous declaration "GetCryptLibHandle:Int64;"
IdSSLOpenSSLHeaders.pas(18191,10) Error: Found declaration: GetCryptLibHandle:QWord;

The following patch avoid this error:

Index: trunk/Lib/Protocols/IdSSLOpenSSLHeaders.pas
===================================================================
--- trunk/Lib/Protocols/IdSSLOpenSSLHeaders.pas    (revision 5478)
+++ trunk/Lib/Protocols/IdSSLOpenSSLHeaders.pas    (working copy)
@@ -832,6 +832,9 @@
   sockets,
   {$ENDIF}
   SysUtils,
+  {$IFDEF FPC}
+  DynLibs,  // better add DynLibs only for fpc
+  {$ENDIF}
   IdCTypes;
 
 //temp for compile tests
@@ -18901,10 +18904,7 @@
   IdGlobalProtocols,
   IdResourceStringsProtocols,
   IdResourceStringsOpenSSL,
-  IdStack
-  {$IFDEF FPC}
-    , DynLibs  // better add DynLibs only for fpc
-  {$ENDIF};
+  IdStack;
 
 {$IFNDEF OPENSSL_NO_HMAC}
 procedure HMAC_Init_ex(ctx : PHMAC_CTX; key : Pointer; len : TIdC_INT;


I'd like to suggest it to Atozed Team. Maybe will be useful to commit in trunk.


Thanks,

G.A. Moennich
(10-18-2018, 11:58 PM)capslock Wrote: [ -> ]Compile package indylaz 10.6.2: Exit code 256, Errors: 2, Hints: 4
IdSSLOpenSSLHeaders.pas(17956,49) Hint: C arrays are passed by reference
IdSSLOpenSSLHeaders.pas(17958,64) Hint: C arrays are passed by reference
IdSSLOpenSSLHeaders.pas(17963,68) Hint: C arrays are passed by reference

Which is fine.  In C and C++, C style arrays decay into a pointer to the first element.  In Pascal, passing an array by reference will pass the same memory address.

(10-18-2018, 11:58 PM)capslock Wrote: [ -> ]IdSSLOpenSSLHeaders.pas(19230,65) Hint: Local variable "LLen" does not seem to be initialized

It is not supposed to be initialized.  That variable is used with an output-only parameter of EVP_DigestFinal_ex().  OpenSSL will assign a value to the variable.

(10-18-2018, 11:58 PM)capslock Wrote: [ -> ]IdSSLOpenSSLHeaders.pas(19571,10) Error: function header doesn't match the previous declaration "GetCryptLibHandle:Int64;"
IdSSLOpenSSLHeaders.pas(18191,10) Error: Found declaration: GetCryptLibHandle:QWord;

Known issue, it was reported to me a month ago:

https://forum.lazarus.freepascal.org/ind...#msg297926

I've opened a ticket for it in Indy's issue tracker:

https://github.com/IndySockets/Indy/issues/234

(10-18-2018, 11:58 PM)capslock Wrote: [ -> ]The following patch avoid this error:

I'd like to avoid using the DynLibs unit in any of Indy's interface sections, if I can avoid it.  But point taken, apparently I can't use HMODULE.  I'll likely just end up using THandle instead, or at least TLibHandle.
(10-19-2018, 07:36 PM)rlebeau Wrote: [ -> ]
(10-18-2018, 11:58 PM)capslock Wrote: [ -> ]Compile package indylaz 10.6.2: Exit code 256, Errors: 2, Hints: 4
IdSSLOpenSSLHeaders.pas(17956,49) Hint: C arrays are passed by reference
IdSSLOpenSSLHeaders.pas(17958,64) Hint: C arrays are passed by reference
IdSSLOpenSSLHeaders.pas(17963,68) Hint: C arrays are passed by reference

Which is fine.  In C and C++, C style arrays decay into a pointer to the first element.  In Pascal, passing an array by reference will pass the same memory address.

(10-18-2018, 11:58 PM)capslock Wrote: [ -> ]IdSSLOpenSSLHeaders.pas(19230,65) Hint: Local variable "LLen" does not seem to be initialized

It is not supposed to be initialized.  That variable is used with an output-only parameter of EVP_DigestFinal_ex().  OpenSSL will assign a value to the variable.

(10-18-2018, 11:58 PM)capslock Wrote: [ -> ]IdSSLOpenSSLHeaders.pas(19571,10) Error: function header doesn't match the previous declaration "GetCryptLibHandle:Int64;"
IdSSLOpenSSLHeaders.pas(18191,10) Error: Found declaration: GetCryptLibHandle:QWord;

Known issue, it was reported to me a month ago:

https://forum.lazarus.freepascal.org/ind...#msg297926

I've opened a ticket for it in Indy's issue tracker:

https://github.com/IndySockets/Indy/issues/234

(10-18-2018, 11:58 PM)capslock Wrote: [ -> ]The following patch avoid this error:

I'd like to avoid using the DynLibs unit in any of Indy's interface sections, if I can avoid it.  But point taken, apparently I can't use HMODULE.  I'll likely just end up using THandle instead, or at least TLibHandle.

Maybe THandle is the best option. I used it in many cross platform projects along years with no problem.