Error: circular reference to variable cause by order (bugs?)
Dakota
dakota at gmail.com
Thu Jul 18 12:25:37 UTC 2024
I am trying to translate some c code into d, get this error:
```d
struct A {
void* sub;
}
struct B {
void* subs;
}
__gshared {
const A[1] a0 = [
{ &b1_ptr },
];
const A[2] a1 = [
{ &b1_ptr },
];
const B b1 = {a1.ptr};
const b1_ptr = &b1;
const A[1] a2 = [
{ &b1_ptr },
];
const B b2 = {a2.ptr};
const b2_ptr = &b2;
}
```
```sh
Error: circular reference to variable `tests.b1_ptr`
```
If I move `a0` after `b2_ptr`, no error any more.
The c code has circular reference type, and compile ok. and there
is a lot type I am not able to adjust order by hand to guess
right order.
the translate code still need to work with C interface, so I can
not change the struct layout. is this a bug of d?
More information about the Digitalmars-d-learn
mailing list