Compiler options fail to replicate fpc -Mtp lazarus / 11-Options ---------------------------------------------------------------------- Ed · 2005-09-26 18:00 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 · 2005-09-27 06:12 Please, give a more complete code sample, including variable and type declarations. ---------------------------------------------------------------------- Anonymous · 2005-09-27 17:46 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 · 2005-09-27 18:02 Yes, but the options passed might be different. ---------------------------------------------------------------------- Vincent Snijders · 2005-09-27 18:10 Somehow, the forum forgot who I am. ---------------------------------------------------------------------- Anonymous · 2005-09-28 00:14 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 "
" exptected "LongInt" Thanks. ---------------------------------------------------------------------- Vincent Snijders · 2005-09-28 06:21 I still can't even try to compile this code. Can you give a complete example including variable and type declarations? ---------------------------------------------------------------------- Marc · 2005-09-28 14:27 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) ---------------------------------------------------------------------- Ed · 2005-09-29 03:20 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 · 2005-09-29 05:39 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 · 2005-09-30 02:42 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 · 2005-10-03 06:34 All I can say is, that this sample app compiles here using fpc 2.0.0 and 2.0.1.