www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21217] New: C++ header generator shouldn't emit private enums

https://issues.dlang.org/show_bug.cgi?id=21217

          Issue ID: 21217
           Summary: C++ header generator shouldn't emit private enums
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: greeenify gmail.com

enums aren't part of the layout, so they shouldn't be emitted. Especially when
they are private:

```
extern(C++) struct Foo {
  int a = 1;
  enum b = 2;
  private enum c = 3;
  protected enum d = 2;
}
```

```
$ dmd -HC -c foo.d
#pragma once

#include <stddef.h>
#include <stdint.h>

#if !defined(ENUM_CONSTANT_NUMERIC)

#endif

struct Foo
{
    int32_t a;
    ENUM_CONSTANT_NUMERIC(int32_t, b, 2)

    ENUM_CONSTANT_NUMERIC(int32_t, c, 3)

    ENUM_CONSTANT_NUMERIC(int32_t, d, 2)

    Foo() : a(1) {}
};
```

--
Sep 03 2020