Wednesday, 15 May 2013

delphi - Make $DEFINE permanent across several modules -


I have a number of projects that use some common code. It is conditionally defined in the project settings and I want to be able to define some of the symbols that continue in many modules. For example:

  {$ if defined is defined (PROJ1_DEBUG) or defined (PROJ1_NDEBUG)} {$ Definition PROJ1} // Project 1 {$ elseif is defined ( PROJ2_DEBUG) or defined (PROJ2_NDEBUG)} {$ Definition PROJ2} // Project 2 {$ elseif is defined (else, PROJ3_DEBUG) or defined (PROJ3_NDEBUG)} {$ PROJ3 Definition} // Project 3 {$ IFEND}  

That's why the main project file can appear on top, now I have projects In many units, you want to be able to use the following conditional compilation:

  {$ ifdef PROJ1} Do some specific work // $ {$ endif} for project {$ ifdef PROJ2} Do not do specific / project 2 {$ endif}  

but I try to find that "PROJ1" and "PROJ2" (and "PROJ3" are obviously not defined) when I try And their use Embarcadero (help) shows my symbols will only be defined for the current module But they will not provide any help to define across multiple modules.

I can define it that it is possible to define more permanent symbols once and then use them across multiple modules?

You have two options:

  1. conditionally defined at the project level Please. From the project options dialog.
  2. Define the conditional inclusion of an included file that you need to test every unit conditional.

No comments:

Post a Comment