Lazarus

Programming => General => Topic started by: ϻαϻɾΣɀО on March 14, 2016, 07:56:30 am

Title: How to determine code complies as Libraray or Program
Post by: ϻαϻɾΣɀО on March 14, 2016, 07:56:30 am
Hi everybody

I have a kind of situation  %), There is some Handler methods and registration procedures,
  In case of Library InternalRegisterHandler(...)
  And for Program RegisterHandler(...)

So if after a while in maintenance of project one or more units moved between Host application(Program) or Module(Library) is there a way to determine code complies under a library or program?

Code: Pascal  [Select][+][-]
  1. Program HostApp;
  2.  
  3. begin
  4.   {$IFDEF PROGRAM}
  5.      Do somthing to change RegisterHandler method...
  6.   {$ENDIF}
  7. end.
----------
Code: Pascal  [Select][+][-]
  1. Library FirstModule;
  2.  
  3. begin
  4.   {$IFDEF LIBRARY}
  5.      Do somthing to change RegisterHandler method...
  6.   {$ENDIF}
  7. end.

Im looking for a way to just determine it, after I made my option to do the rest of things....
Title: Re: How to determine code complies as Libraray or Program
Post by: marcov on March 14, 2016, 09:58:21 am
Within units this would be very shaky anyway, since the compilation could be fragmented

Code: [Select]
// compile units

fpc unit1
fpc unit2

// compile mainprogram and library that use units:
fpc mainprogram.lpr

fpc library.lpr

In that case, while compiling units1 and units2, the compiler doesn't know if the mainprogram or the library or both are being built after.

Moral of the story: the only solution is to define a conditional yourself in the project, and then always use BUILD to build the library (so that the units are forcedly compiled)
TinyPortal © 2005-2018