Recent

Author Topic: Compiler options fail to replicate fpc -Mtp  (Read 13233 times)

Ed

  • Guest
Compiler options fail to replicate fpc -Mtp
« on: September 26, 2005, 08:00:55 pm »
I was migrating code from Turbo Pascal 7 for DOS to linux, and have most of it compiling using the command line fpc source -Mtp.  I just started using Lazarus.  I get new errors, and have now chosen ONLY the -So option for the project compiler options.  It still gives a pointer to a procedure error that -Mtp does not.  I see no other source code tricks I can use to sidestep the compiler error, so feel that I need to keep the pointer comparison such as:

IntHandler: pointer;

If (IntHandler <> @SomeIntHandler) then...

I tried the $T+ and $T-, but nothing changes.  I get "expected longint but got ^procedure(Word,word...)

I see no way to force any other options, or specifically -Mtp.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: Compiler options fail to replicate fpc -Mtp
« Reply #1 on: September 27, 2005, 08:12:56 am »
Please, give a more complete code sample, including variable and type declarations.

Anonymous

  • Guest
Re: RE: Compiler options fail to replicate fpc -Mtp
« Reply #2 on: September 27, 2005, 07:46:52 pm »
Quote from: "Vincent"
Please, give a more complete code sample, including variable and type declarations.


I will do that, but the code is at home.  Tthe main part of the question is why does the command line execution of fpc compile but the same code from Lazarus does not?  Lazarus runs the same compiler, does it not?

Anonymous

  • Guest
RE: Re: RE: Compiler options fail to replicate fpc -Mtp
« Reply #3 on: September 27, 2005, 08:02:49 pm »
Yes, but the options passed might be different.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: Re: RE: Compiler options fail to replicate fpc -Mtp
« Reply #4 on: September 27, 2005, 08:10:06 pm »
Somehow, the forum forgot who I am.

Anonymous

  • Guest
Compiler options fail to replicate fpc -Mtp
« Reply #5 on: September 28, 2005, 02:14:16 am »
The code is

Procedure SetInterrupts(IntHandler: Pointer; InterruptFrequency: Single);
Begin
   Asm
      CLI;   //Inline($FA);                         {CLI - disable interrupts during vector change}
   end;
   If (IntHandler <> @RUSHandler) then

I keep getting Error: Incompatible types: got "<address of procedure(Word, Word, Word, Word, Word, Word...); Register>" exptected "LongInt"

Thanks.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Compiler options fail to replicate fpc -Mtp
« Reply #6 on: September 28, 2005, 08:21:59 am »
I still can't even try to compile this code. Can you give a complete example  including variable and type declarations?

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2530
Compiler options fail to replicate fpc -Mtp
« Reply #7 on: September 28, 2005, 04:27:00 pm »
I can reproduce it with the following app:
Code: [Select]

program a;


procedure RUSHandler(a,b,c,d,e,f: Word);
begin
end;

Procedure SetInterrupts(IntHandler: Pointer; InterruptFrequency: Single);
Begin
  Asm
    CLI; //Inline($FA); {CLI - disable interrupts during vector change}
  end;
  If (IntHandler <> @RUSHandler) then
end;

begin
end.


When you compile like this, without specifying mode, fpc compiles in its native fpc mode. This mode is similar to tp.
Somehow the result of @ is typed on comparisations.

As a workaround you can typecast: -> Pointer(@RUSHandler)

For a better explanation, you can thry the fpc forum or the fpc mailinglist, since this is not realy a lazarus issue (and I'm not that deep into the fpc internals of different modi)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Ed

  • Guest
Compiler options fail to replicate fpc -Mtp
« Reply #8 on: September 29, 2005, 05:20:17 am »
Thanks.  My point was that the snippet of code I gave (more complete code is like that proposed by Marc) compiles just fine with the command line

fpc -Mtp source.pas

but does not with Lazarus when I specify the -So compile option, which is supposed to be equivalent to -Mtp.  I wanted to know how to perfectly replicate fpc -Mtp to successfully compile my source from within Lazarus.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: Compiler options fail to replicate fpc -Mtp
« Reply #9 on: September 29, 2005, 07:39:43 am »
Thanks, Marc, for the complete example. Now, at least, I can reproduce the problem and see for myself that your example code only needs the -So parameter (and that it is equivalent to -Mtp). No need to change the code.

I cannot reproce the problems Ed is having, because I cannot compile his snippet
Code: [Select]
project1.pas(9,20) Error: Identifier not found "RUSHandler"

Ed

  • Guest
Compiler options fail to replicate fpc -Mtp
« Reply #10 on: September 30, 2005, 04:42:25 am »
Here is a distilled program:

Program TestHandler;

Procedure RUSHandler(Flags,CS,IP,AX,BX,CX,DX,SI,DI,DS,ES,BP: Word);
Begin
end; {RUSHandler}

Procedure SetInterrupts(IntHandler: Pointer; InterruptFrequency: Single);
Begin
  If (IntHandler <> @RUSHandler) then
    {do something}
end;

Begin {Main program}
  SetInterrupts(@RUSHandler, 5000.0)
end.

I verified that Lazarus was using no optons but -So, and it still had a compiler error that I do not get when I invoke the compiler from the command line with -Mtp.  I do see that the forced typecasting as suggested by Marc "Pointer((@RUSHandler)" did work, so this becomes less important.  I still wonder why the results differ...

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: Compiler options fail to replicate fpc -Mtp
« Reply #11 on: October 03, 2005, 08:34:23 am »
All I can say is, that this sample app compiles here using fpc 2.0.0 and 2.0.1.

 

TinyPortal © 2005-2018