Recent

Author Topic: Mode MacPas Compile time variables  (Read 6913 times)

Joel

  • Newbie
  • Posts: 5
Mode MacPas Compile time variables
« on: February 09, 2011, 07:57:21 pm »
We are working with a common codebase between a variety of platforms that requires MacPas mode.  However, compiling on Windows with Lazarus has an issue.  According to the wiki page at: http://wiki.lazarus.freepascal.org/Mode_MacPas , setting -Mmacpas should support both $IFC commands and compiletime variables.  However, this doesn't seem to be the case.

Looking under Compiler Options, there doesn't seem to be a place to specifically add any -d defines, so we put them in Other -> Custom Options.  We'd add something like this: -dTarget_Windows:=TRUE .  However, if we then do {$IFC Target_Windows} it complains that this is an unknown identifier.  We can set the variable with {$SETC Target_Windows:=TRUE}, but this is not a particularly helpful solution.

Is this a bug in FPC/Lazarus, or are we simply missing the correct place to define compile time variables?

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Mode MacPas Compile time variables
« Reply #1 on: February 09, 2011, 08:06:48 pm »
The Other tab's Custom options is the correct place to puts defines.

A define is either defined or not defined, so do it this way:

-dTarget_Window

You probably defined this: "Target_Window:=True".

Thanks.

-Phil

Joel

  • Newbie
  • Posts: 5
Re: Mode MacPas Compile time variables
« Reply #2 on: February 09, 2011, 10:55:34 pm »
Thanks for your reply, Phil.  The issue is that we need to define a compile time variable as true or false, not defined or undefined.  According to the linked wiki, I should be able to do Target_Windows:=TRUE as a -d, but it doesn't seem to work.

The reason we cannot just use normal definitions and $IFDEF, and why we are using macpas mode, is due to crossplatform compatibility.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Mode MacPas Compile time variables
« Reply #3 on: February 09, 2011, 11:09:51 pm »
If you really need to define with -d switch, then you should probably file a bug report. First determine if FPC will accept this ":=" syntax on the command line. If not, file bug with FPC; if it does, then probably Lazarus is not passing it through properly, so file with Lazarus.

Did you try putting the entire value in quotes" (-d"Target_Window:=TRUE").

What version of FPC and Lazarus are you using? Be sure to use at least FPC 2.4.2 and a recent 0.9.29 snapshot.

Why exactly do you need MacPas mode in the first place? If you have ancient MacPascal code, you might want to consider bringing it into the world of Delphi syntax.

Thanks.

-Phil

Joel

  • Newbie
  • Posts: 5
Re: Mode MacPas Compile time variables
« Reply #4 on: February 10, 2011, 12:03:11 am »
My guess is it is a bug in Lazarus.  When using FPC on Mac OS X in XCode, -dTarget_Windows:=TRUE works just fine without quotes.  We are using the latest released build of Lazarus and the FPC that came with that.  I believe that is 0.9.28 and 2.2.4, respectively.  We'll try upgrading both to the latest to see if that makes a difference, and with the quotes.  If neither helps, we'll file a bug with Lazarus (Though we don't have an account on the bugtracker yet).  Thanks for your help.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Mode MacPas Compile time variables
« Reply #5 on: February 10, 2011, 01:13:50 am »
A recent 0.9.29 snapshot should be close to what 0.9.30 will be and can be considered a release candidate. New development is going on in the 0.9.31 branch of SVN. 0.9.28 is about 1.5 years old, so any number of things might have been fixed, including the passing of switches to FPC.

If you're new to Lazarus on Mac, you might take a peek at this short article for ideas on how to get a more Mac-like program out of Lazarus:

http://web.me.com/macpgmr/ObjP/MacXPlatform_Part8.html

Thanks.

-Phil

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12851
  • FPC developer.
Re: Mode MacPas Compile time variables
« Reply #6 on: February 10, 2011, 11:42:47 am »
(Hmm, I thought that -dxx:=yyy defines a macro

found the link:

http://bugs.freepascal.org/view.php?id=12935)

« Last Edit: February 14, 2011, 04:27:15 pm by marcov »

Joel

  • Newbie
  • Posts: 5
Re: Mode MacPas Compile time variables
« Reply #7 on: February 22, 2011, 11:15:35 pm »
Thanks again for the replies, and sorry about the delay in getting back to you.

We've updated to 0.9.31 and FPC 2.4.3, but still no fix.  We know its not a problem with the compiler, as defining them identically on OS X works fine.

I looked at the bug report, Marco, but it didn't seem specifically relevant.  We do know that defining '-dTarget_Windows:=TRUE' works on OS X (XCode), but not on Lazarus for Windows.

If this is a bug in Lazarus, what's the best way of submitting it?

Alternatively, we saw that there is an area for Build Macros and Conditionals for them.  Would there be some way for us to use this?  It doesn't matter how we define it as long as the end result is that {$IFC Target_Other} would return false and be skipped, but {$IFC Target_Windows} would return true and be run.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Mode MacPas Compile time variables
« Reply #8 on: February 23, 2011, 12:18:47 am »
Have you tracked down whether it's supported with FPC on Windows? If not, then report as an FPC bug; if so, then probably a Lazarus bug, so report as Laz bug.

Thanks.

-Phil

 

TinyPortal © 2005-2018