January 30, 2023 [Issue 23662] New: ImportC bad handling of enum arguments for a function | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: bugzilla@digitalmars.com >From Dmytro Katyukha <firemage.dima@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` ``` -- |
Copyright © 1999-2021 by the D Language Foundation