[Issue 23662] New: ImportC bad handling of enum arguments for a function
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Jan 30 23:10:32 UTC 2023
    
    
  
https://issues.dlang.org/show_bug.cgi?id=23662
          Issue ID: 23662
           Summary: ImportC bad handling of enum arguments for a function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at digitalmars.com
>From Dmytro Katyukha <firemage.dima at gmail.com>:
It seems that ImportC does not allow to pass enums declared with typedef but
without tag to function that receives enum as one of argument
## The code snippets:
```c
// testlib.c
typedef enum /*enum_test_1_t*/ {
    E_TEST_1_ITEM_1 = 1,
    E_TEST_1_ITEM_2,
} enum_test_1_t;
int some_func(enum_test_1_t val) {
    return val;
}
```
```d
//test.d
import testlib;
void main(string[] args) {
    enum_test_1_t val1 = E_TEST_1_ITEM_1;
    some_func(E_TEST_1_ITEM_1);
}
```
## Attempt to compile produce following output
```
dmd test.d testlib.c
test.d(6): Error: function `testlib.some_func(__tag2 val)` is not callable
using argument types `(__anonymous)`
test.d(6):        cannot pass argument `E_TEST_1_ITEM_1` of type `__anonymous`
to parameter `__tag2 val`
```
--
    
    
More information about the Digitalmars-d-bugs
mailing list