Einzelnen Beitrag anzeigen

Rollo62

Registriert seit: 15. Mär 2007
4.093 Beiträge
 
Delphi 12 Athens
 
#2

AW: Sharing the same unit between projects

  Alt 10. Dez 2020, 12:52
The problem with missing include files is very annoying.
You have the possibility to add a define in the IDE global project options, defines section for each project.
E.g.
Global Define: _X_USE_MY_UNITS

Delphi-Quellcode:
{$IF DEFINED( _X_USE_MY_UNITS ) }
{$INCLUDE MyUnit }  //<== declares maybe _X_USE_MY_SPECIAL_UNIT_1, ...
{$ENDIF }

Uses
{$IF DEFINED( _X_USE_MY_SPECIAL_UNIT_1 ) }
    MySpecialUnit1,
{$ENDIF }
{$IF DEFINED( _X_USE_MY_SPECIAL_UNIT_2 ) }
    MySpecialUnit2,
{$ENDIF }
{$IF DEFINED( _X_USE_MY_SPECIAL_UNIT_3 ) }
    MySpecialUnit3,
{$ENDIF }
   ...
{$IF     DEFINED( MY_VARIANT_UNIT_1 ) }
    MyVariantUnit1,
{$ELSEIF DEFINED( MY_VARIANT_UNIT_2 ) }
    MyVariantUnit2,
{$ELSEIF DEFINED( MY_VARIANT_UNIT_3 ) }
    MyVariantUnit3,
{$ENDIF }

    LastUnit
  ;
Would be much nicer, if could be detected if Include file is declared or not.

Geändert von Rollo62 (10. Dez 2020 um 12:57 Uhr)
  Mit Zitat antworten Zitat