ImportC with typedef anonymous enums
rmc
rjmcguire at gmail.com
Wed Nov 9 17:48:14 UTC 2022
Could we make enums work the way structs do in importC?
For example (example2d.d):
```
import example2;
void main() {
my_struct param;
my_enum eopt;
//param.opts = A; // not okay
someFunc(param);
someFunc2(param.opts); // okay
someFunc2(eopt); // not okay
}
```
Error is:
```
example2d.d(10): Error: function `example2.someFunc2(__tag3
evalue)` is not callable using argument types `(__anonymous)`
example2d.d(10): cannot pass argument `eopt` of type
`__anonymous` to parameter `__tag3 evalue`
```
example2.c:
```
int printf(const char *format, ...);
typedef enum {
A = 1,
B = 1 << 1,
} my_enum;
typedef struct {
int i;
my_enum opts;
} my_struct;
void someFunc(my_struct s) {
printf("okay\n");
}
void someFunc2(my_enum evalue) {
printf("okay2\n");
}
// void main() {
// my_struct param;
// my_enum eopt;
// param.opts = A; // okay
// someFunc(param);
// someFunc2(param.opts); // okay
// someFunc2(eopt); // okay
// }
```
More information about the Digitalmars-d
mailing list