From Dmytro Katyukha <[email protected]>:
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`
```
dlang/dmd pull request #14859 "Fix Issue 23662: ImportC bad handling of enum arguments for a function" was merged into stable:
- 26358e7106349f319f94f28bd152ee4b9614e63f by Dmytro Katyukha:
Added testcase for Issue 23662
See: https://issues.dlang.org/show_bug.cgi?id=23662
- 5e72b01d56594288a6c43683a06eccb61d74df7b by Dmytro Katyukha:
Fix Issue 23662
https://github.com/dlang/dmd/pull/14859
Comment #3 by dlang-bot — 2023-02-13T03:29:12Z
dlang/dmd pull request #14875 "merge stable" was merged into master:
- 582dd6c1a1c8f2fc07498c3787dd5b878dac79b3 by Dmytro Katyukha:
Fix Issue 23662: ImportC bad handling of enum arguments for a function (#14859)
* Added testcase for Issue 23662
See: https://issues.dlang.org/show_bug.cgi?id=23662
* Fix Issue 23662
https://github.com/dlang/dmd/pull/14875