Recent

Author Topic: External variables in Delphi mode  (Read 585 times)

Wallaby

  • Jr. Member
  • **
  • Posts: 79
External variables in Delphi mode
« on: February 14, 2023, 06:27:25 am »
I need to use a couple of external variables in my unit written for {$MODE DELPHI}. Unfortunately the following doesn't compile:

Code: Pascal  [Select][+][-]
  1. kDADiskDescriptionWatchVolumeName: CFArrayRef; cvar; external;

It does compile in {$MODE OBJFPC}, but in that mode FPC doesn't compile my remaining code.

Is there a way to declare an external variables in {$MODE DELPHI}?

Wallaby

  • Jr. Member
  • **
  • Posts: 79
Re: External variables in Delphi mode
« Reply #1 on: February 14, 2023, 06:58:37 am »
Answering my own question, just need to remove a semicolon before cvar:

Code: Pascal  [Select][+][-]
  1. kDADiskDescriptionWatchVolumeName: CFArrayRef cvar; external;

TRon

  • Hero Member
  • *****
  • Posts: 2515
Re: External variables in Delphi mode
« Reply #2 on: February 14, 2023, 07:15:20 am »
you are correct. also for the alternative form:
Code: Pascal  [Select][+][-]
  1. var
  2.   MyVar : integer; external name 'varname';
  3.  
you seem to need to remove the semicolon between integer and external in mode Delphi.

Strange that it is not mentioned in the documentation

PascalDragon

  • Hero Member
  • *****
  • Posts: 5481
  • Compiler Developer
Re: External variables in Delphi mode
« Reply #3 on: February 15, 2023, 11:03:03 pm »
Strange that it is not mentioned in the documentation

Because not every gritty, bitty detail of the compiler is known to who is writing the documentation.

 

TinyPortal © 2005-2018