Special Enums (The GNU D Compiler)

### 2.8 Special Enums ¶

Special `enum` names are used to represent types that do not have an equivalent basic D type. For example, C++ types used by the C++ name mangler.

Special enums are declared opaque, with a base type explicitly set. Unlike regular opaque enums, special enums can be used as any other value type. They have a default `.init` value, as well as other enum properties available (`.min`, `.max`). Special enums can be declared in any module, and will be recognized by the compiler.

    import gcc.builtins;
    enum __c_long : __builtin_clong;
    __c_long var = 0x800A;

The following identifiers are recognized by GNU D.

`__c_complex_double`

  C `_Complex double` type.

`__c_complex_float`

  C `_Complex float` type.

`__c_complex_real`

  C `_Complex long double` type.

`__c_long`

  C++ `long` type.

`__c_longlong`

  C++ `long long` type.

`__c_long_double`

  C `long double` type.

`__c_ulong`

  C++ `unsigned long` type.

`__c_ulonglong`

  C++ `unsigned long long` type.

`__c_wchar_t`

  C++ `wchar_t` type.

The `core.stdc.config` module declares the following shorthand alias types for convenience: `c_complex_double`, `c_complex_float`, `c_complex_real`, `cpp_long`, `cpp_longlong`, `c_long_double`, `cpp_ulong`, `cpp_ulonglong`.

It may cause undefined behavior at runtime if a special enum is declared with a base type that has a different size to the target C/C++ type it is representing. The GNU D compiler will catch such declarations and emit a warning when the `-Wmismatched-special-enum` option is seen on the command-line.