Recent

Author Topic: Global defines?  (Read 10635 times)

masonwheeler

  • New Member
  • *
  • Posts: 19
Global defines?
« on: January 08, 2008, 07:34:37 pm »
I'm porting a project from Delphi.  Some of the code includes shared libraries, which use global (project-level) defines to turn on and off certain parts of the code.  Apparently that didn't get translated, and I can't find the option in the Project Options either.  I wasn't even able to find anything about it through several different web searches!  So I'll ask here.  How do I set global $defines for the entire project?

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Global defines?
« Reply #1 on: January 08, 2008, 07:41:05 pm »
Quote from: "masonwheeler"
I'm porting a project from Delphi.  Some of the code includes shared libraries, which use global (project-level) defines to turn on and off certain parts of the code.  Apparently that didn't get translated, and I can't find the option in the Project Options either.  I wasn't even able to find anything about it through several different web searches!  So I'll ask here.  How do I set global $defines for the entire project?


In Compiiler Options, on the Other tab, you can enter switches in Custom options. Example: to define a conditional named "MYCOND", enter -dMYCOND under Custom options.

Thanks.

-Phil

masonwheeler

  • New Member
  • *
  • Posts: 19
RE: Re: Global defines?
« Reply #2 on: January 09, 2008, 02:21:43 am »
Great! Now do you know how to globally turn on assertions throughout the project?  Apparently just checking the option in Compiler Options -> Parsing isn't enough, and it would be a real pain to add {$Assertions} to every single unit in my project.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Re: Global defines?
« Reply #3 on: January 11, 2008, 03:45:33 am »
Quote from: "masonwheeler"
Great! Now do you know how to globally turn on assertions throughout the project?  Apparently just checking the option in Compiler Options -> Parsing isn't enough, and it would be a real pain to add {$Assertions} to every single unit in my project.


Turning on assertions on the Parsing panel should enable assertions in your code globally unless you've got some local switches in some units that are turning assertions off. I think in Delphi the switch is {$C-} -- grep for that.

Thanks.

-Phil

masonwheeler

  • New Member
  • *
  • Posts: 19
RE: Re: RE: Re: Global defines?
« Reply #4 on: January 11, 2008, 08:48:00 pm »
Nope.  No switches like that anywhere in my code.  The codebase was built with heavy use of assertions; there's no reason to explicitly turn them off.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Re: RE: Re: Global defines?
« Reply #5 on: January 11, 2008, 10:54:51 pm »
Quote from: "masonwheeler"
Nope.  No switches like that anywhere in my code.  The codebase was built with heavy use of assertions; there's no reason to explicitly turn them off.


I use assertions too and haven't noticed any problem, but that doesn't mean it isn't broken.

Here's some things to try:

- Look at the .compiled file and see if the -Sa switch is included.

- You can also compile from the command line with FPC or LazBuild and see if that makes any difference. You can also use the -va switch with FPC to see absolutely everything that FPC is doing. That might help in tracking down the problem. Example:

fpc -va myprog.pas >listing.txt

- Can you create a small example that illustrates the problem?

Thanks.

-Phil

masonwheeler

  • New Member
  • *
  • Posts: 19
RE: Re: RE: Re: RE: Re: Global defines?
« Reply #6 on: January 12, 2008, 09:15:50 pm »
I checked the .compiled file, and sure enough, no -Sa switch.  So I deleted the file (and all my .o and .ppu files), and did a Full Build.  It generated a new .compiled file.  I checked this one.  STILL no -Sa switch.  I checked in Compiler Settings and... yep! It's checked.  It's just not quite making it to the .compiled file.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Re: RE: Re: RE: Re: Global defines?
« Reply #7 on: January 12, 2008, 11:45:12 pm »
Quote from: "masonwheeler"
I checked the .compiled file, and sure enough, no -Sa switch.  So I deleted the file (and all my .o and .ppu files), and did a Full Build.  It generated a new .compiled file.  I checked this one.  STILL no -Sa switch.  I checked in Compiler Settings and... yep! It's checked.  It's just not quite making it to the .compiled file.


I'm not seeing that here. My .compiled files show -Sad since those are the only two boxes I have checked on the Parsing tab.

What version of Lazarus and FPC are you using? I'm using the Windows snapshot from 20080105 with FPC 2.2.1.

You might take a look at the IDE code that creates the .compiled file, etc. If this is a bug it should be easy to spot. Then you could post a patch or a bug report about it. The Compiler Options dialog appears to be undergoing a revision - hence why there's two of them - so maybe something got broken.

Thanks.

-Phil

masonwheeler

  • New Member
  • *
  • Posts: 19
RE: Re: RE: Re: RE: Re: RE: Re: Global defines?
« Reply #8 on: January 13, 2008, 01:50:05 am »
Version: 0.9.24 beta
Date: 1/8/2008
SVN Revision: 12752
i386-win32-win32/win64

I didn't know it lumps all the compiler flags together in the .compile file.  Mine says -S2cadgit, which includes the a flag (now that I know what to look for, it's easy to find).  I just tested it again, and if I delete the .o and .ppu files, it rebuilds correctly with assertions working properly.  So this would seem to be simply another manifestation of the bug I reported here, which was resolved by the same method.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Re: RE: Re: RE: Re: RE: Re: Global defines?
« Reply #9 on: January 13, 2008, 02:30:27 am »
Quote from: "masonwheeler"
Version: 0.9.24 beta
Date: 1/8/2008
SVN Revision: 12752
i386-win32-win32/win64

I didn't know it lumps all the compiler flags together in the .compile file.  Mine says -S2cadgit, which includes the a flag (now that I know what to look for, it's easy to find).  I just tested it again, and if I delete the .o and .ppu files, it rebuilds correctly with assertions working properly.  So this would seem to be simply another manifestation of the bug I reported here, which was resolved by the same method.


Yes, I have batch files and scripts that I use regularly to get rid of intermediate files, mostly to eliminate clutter. For example, on Windows:

erase *.o
erase *.ppu
erase *.a
erase *.or
erase *.dcu
erase *.~??
erase *.bak
erase *.ddp

Thanks.

-Phil

masonwheeler

  • New Member
  • *
  • Posts: 19
RE: Re: RE: Re: RE: Re: RE: Re: RE: Re: Global defines?
« Reply #10 on: January 13, 2008, 04:18:03 am »
Well, that's the third major hurdle so far.  Now if someone could figure out a similarly easy solution to this one I could probably get my project running! :D  Thanks for all your help!

 

TinyPortal © 2005-2018