delphicompiler-warningscompiler-directives

Compiler directives deleted from DPR file


Question
How do I make a compiler directive stay in the DPR file?

Description
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.
If I put it in DPK files, the IDE will delete it every time I change the Project Options (we know that at when changing the options, the DPK file gets partially rebuilt).

To reproduce it

Scope
This issue does not explicitly concentrates on "DUPLICATE_CTOR_DTOR" but in general on user-added "text" in DPR files.


Solution

  • 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