Re: [Freedos-devel] Problem with procedural types in 16-bit DOS FreePascal

2022-11-06 Thread Jerome Shidel
I’m not at my computer right now. So, this will just be rather vague….

Although I’ve used FPC/Lazarus for some things, I haven’t used it to create 
stuff to run under DOS. But, I have seen some weirdness regarding this sort of 
thing when targeting current GUIs. I forget  the exact details. However, there 
a few things you might try if you have not already.

Make sure your compiling to the correct memory model. (I think huge, but you’ll 
need to double check that)

You may need to ensure the actual procedure is declared with far.

Procedure Test; far;
Begin
End;

Also, you may need assign the address to a plain pointer and typecast the call.

Type 
  MyProc = procedure;

Var
  P : pointer;

Begin
P := @Test;
MyProc(P^);
End.

Also, there are also compiler directives for FPC regarding compatibility. 

Jerome




___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


[Freedos-devel] Problem with procedural types in 16-bit DOS FreePascal

2022-11-06 Thread Aitor Santamaría
Hello,

I am trying to recompile FD-KEYB using 16-bit DOS FreePascal, in order to
see if I can produce a FPC version and thus avoid using TPC for compiling.

I am not being very lucky with compiling itself, and I haven't raised too
much attention in the FPC lists, either because it is difficult, or most
probably, compiling for an old 16-bit OS does not raise too much interest.

So I am trying this list here, in case some of you have ever mangled 16-bit
FPC and know the answer.

The biggest problem I am having is with the procedural type variables.
Whereas TPC would swallow this:

VAR
   v: procedure;

procedure P;
begin
...
end;

v := P;

FPC does not like it, as it is trying to assign the RESULT of P (untyped)
to v.

KEYB.PAS(2960,21) Error: Incompatible types: got "untyped" expected
""

The documentation tells me to use

v := @P;

but it does not work, it gives:

KEYB.PAS(2960,21) Error: Illegal type conversion: "" to ""

which puzzles me, because to my  mind, they are the same thing.


Using -MTP compiler option does not help, I get lots of new errors, unless
I avoid it by

TYPE
SimpleProc = procedure; far; { parameter-less callable
function }

(which is NOT standard TP language at all), but would in turn give me:

KEYB.PAS(2960,21) Error: Illegal type conversion: "" to "NearCsPointer"

You can read the full thread here:
Far pointer versus Pointer in 16-bit DOS (freepascal.org)



Any hints on how to circumvent this problem?

Thanks in advance,
Aitor
___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel