Gad D Lord
Gad D Lord

Reputation: 6772

How to mark as deprecated a single enum value in Delphi

I wish to have the following:

TEnumType = (
  etValue1 = 1,
  etValue2 = 2 deprecated,
  etValue3 = 3);

It returns:

[DCC Error] unt_CollectionImportType.pas(19): E2029 ',' or ')' expected 
but identifier 'deprecated' found.

Is there a way to instruct the compiler that this value is deprecated.

Upvotes: 18

Views: 915

Answers (1)

Zoë Peterson
Zoë Peterson

Reputation: 13322

type
  TEnumType = (
    etValue1 = 1,
    etDeprecated2 = 2, // was: etValue2; Renamed so we can deprecate it by name
    etValue3 = 3);

const
   etValue2 = etDeprecated2 deprecated; // Declares a constant mapped to the renamed enum value.

Upvotes: 36

Related Questions