www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - =?UTF-8?B?W0lzc3VlIDIyNzM0XSBOZXc6IGltcG9ydEM6IHR5cGVkZWbigJlk?=

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

          Issue ID: 22734
           Summary: importC: typedef’d anonymous enum’s members not
                    available when used from D.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dave287091 gmail.com

With the following C file:

// enu.c
enum E_a {
    A,
};
enum {
    B,
};

typedef enum {
    C,
} E_c;

typedef enum E_d {
    D,
} E_d;

int a = A;
int b = B;
int c = C;
int d = D;


Which is then imported by the following D file:

// use_enu.d
import enu;

auto d_a = A;
auto d_b = B;
auto d_c = C;
auto d_d = D;

You get the following errors:

enu.c(19): Error: undefined identifier `C`
use_enu.d(6): Error: undefined identifier `C`

What is odd though is that if you compile enu.c directly:

    dmd enu.c -c

You get no error, it is when you compile a D file 

     dmd use_enu.d -c

that you get the above errors.

--
Feb 03 2022