Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Header Generation    [ Add a report in this area ]  
Report #:  92477   Status: Closed
DCC doesn't emit underlying enum types
Project:  C++Builder Build #:  15.0
Version:    15.1 Submitted By:   Luis Branca
Report Type:  Minor failure / Design problem Date Reported:  3/22/2011 10:57:04 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   282349
Resolution: Fixed (Resolution Comments) Resolved in Build: : 16.0.4201.40972
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: 20
Forward declaration for enums generated by the delphi compiler is not currently possible because it's underlying type is missing. This could have been implemented since D2009, because of it's partial support for C++0x (which brought that feature into the C++ realm).

Currently it's still not possible to forward declare some enums from the VCL like TFieldType, TFieldKind, TLocateOption because auto generated hpp's do not propagate their underlying type as in:

enum TFieldType : BYTE { ftUnknown, (...), ftSingle };
enum TFieldKind : BYTE { fkData, fkCalculated, fkLookup, fkInternalCalc, fkAggregate };
enum TLocateOption : BYTE { loCaseInsensitive, loPartialKey };

This really would open the way to have extremely clean and lean headers (and way faster compilations).

More information in
Steps to Reproduce:
To bypass inclusion of Db.hpp on a header, try to use

  namespace Db { // #include <DB.hpp>
    enum TLocateOption : BYTE;
  } using Db::TLocateOption;

it won't compile (type mismatch?).
There is no way on the C++ specs to forward declare an enum it we do not specify it's underlying type.
Manually edit and patch all auto generated enums from VCL's .hpp files that we intend to use on forward declarations, adding the missing underlying type (as exemplified above).


Server Response from: ETNACODE01