Recent

Author Topic: IRpcChannelBuffer.FreeBuffer definition problem  (Read 589 times)

440bx

  • Hero Member
  • *****
  • Posts: 6368
IRpcChannelBuffer.FreeBuffer definition problem
« on: July 02, 2025, 07:10:17 am »
Hello,

In activex.pp, IRpcChannelBuffer.FreeBuffer is defined as:
Code: Pascal  [Select][+][-]
  1.        Function FreeBuffer(Const pMessage : RPCOLEMESSAGE):HResult; StdCall;
  2.  
where "pMessage" is specified as "const".

The C/C++ definition is:
Code: C  [Select][+][-]
  1.         virtual HRESULT STDMETHODCALLTYPE FreeBuffer(
  2.             /* [annotation][out][in] */
  3.             _Inout_  RPCOLEMESSAGE *pMessage) = 0;
  4.  
Notice that the parameter is "inout" indicating that the values in the structure are modified, IOW, they are NOT "const".

In addition to misleading, it is questionable to rely on "const" passing the parameter by reference given that it is explicitly documented that FPC may decide not to pass a const parameter by reference.

The parameter should be "var".
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018