Recent

Author Topic: Redefine interface  (Read 849 times)

quantumfoam

  • New Member
  • *
  • Posts: 14
Redefine interface
« on: October 27, 2021, 02:49:22 pm »
I'm trying to translate C++ header files into Pascal. There is lot of cases where interface (just name) is defined:
Code: Pascal  [Select][+][-]
  1. INTF1 = interface;

Then it is used in some completely defined interface:
Code: Pascal  [Select][+][-]
  1. INTF2 = interface(INTF_BASE)
  2.  function intf2_a(p:INTF1):int; stdcall;
  3. end;
  4.  

And lastly, the interface is fully defined:
Code: Pascal  [Select][+][-]
  1. INTF1 = interface(INTF_BASE)
  2.  function intf1_x:int; stdcall;
  3. end;
  4.  

When I try to do this in Free Pascal, I get Duplicate identifier error. How can I redefine interface?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9691
  • FPC developer.
Re: Redefine interface
« Reply #1 on: October 27, 2021, 04:19:06 pm »
The first declaration is a forward define, and the INTF1 declaration later is fine.

If not, what is your exact code, and what exact error do you get?

quantumfoam

  • New Member
  • *
  • Posts: 14
Re: Redefine interface
« Reply #2 on: October 27, 2021, 04:53:06 pm »
The error was "Duplicate identifier". And the reason was, I had the forward declaration in reality defined like

Code: Pascal  [Select][+][-]
  1. INTF1 = interface end;

not as actually wrote in question

Code: Pascal  [Select][+][-]
  1. INTF1 = interface;

These damn Pascal beginners. :) Thanks.

 

TinyPortal © 2005-2018