Home > Blockchain >  {$WARN DUPLICATE_CTOR_DTOR OFF} gets deleted from Dpk file
{$WARN DUPLICATE_CTOR_DTOR OFF} gets deleted from Dpk file

Time:04-06

I need to turn off this compiler warning because I don't intend to make my library compatible with C .

If I put the compiler directive in the PAS file that generates the warning, it is ignored.

People on the mighty internet say that {$WARN DUPLICATE_CTOR_DTOR OFF} should be placed in the DPR file. However, if I put it there, the IDE will delete it every time I change the Project Options (we all know that at when changing the options, the DPR file gets partially rebuilt).


Update: Sorry. My mistake! It only happens with DPK files. I got the impression that the bug appears also in the DPR but it does not.

To reproduce it:

  • Start Delphi 10.4,
  • start a new Delphi package (File main menu)
  • add {$ENDIF IMPLICITBUILDING} after {$IMPLICITBUILD ON}.
  • now open Project Options, change something and close the dialog.

The IMPLICITBUILDING directive will be gone.

CodePudding user response:

Go to Project>Options>Building>Delphi Compiler>Hints and Warnings, select the platform and configuration, then set that warning to False. And Save. (Depending on your version of Delphi, the exact location of this setting might be different.) Screenshot of warning setting

CodePudding user response:

In the following DPR file all these lines remain as-is in Delphi 7, even if IDE wise something is saved/changed/added:

// My comment
{.$DEFINE MEMCHECK}
{$DEFINE BOMB}
// JCL_DEBUG_EXPERT_GENERATEJDBG ON
// JCL_DEBUG_EXPERT_INSERTJDBG ON
program pMain;

{$SetPEFlags $c20}
{.$define FullDebugMode}
{$I all.inc}

uses
  FastMM4,
  madExcept,

As you see I set a few compiler directives, while others are commented out (the leading dot makes it only a Pascal comment). Comments and empty lines also remain - nothing is rewritten there, especially not the directives. That's why I ask for a code example by you: you might use a position in your code other than these. Or a Delphi version which behaves differently.

Even if the IDE would rebuild your DPR from scratch you should be able to add a unit to your project that comes first, and in that you put your compiler directive. Compiler wise this must be encountered first then. But I have no clue why you don't do so and never will have a clue without code examples by you.

  • Related