On Friday, 30 July 2021 at 21:53:48 UTC, russhy wrote:
On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote:
I get want to define this struct in D:
```c
struct test1 {
struct test1 *prev;
struct test1 *next;
size_t v1;
size_t v2;
size_t v3;
char data[];
};
```
```d
st
On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote:
I get want to define this struct in D:
```c
struct test1 {
struct test1 *prev;
struct test1 *next;
size_t v1;
size_t v2;
size_t v3;
char data[];
};
```
```d
struct test1 {
test1 *prev;
test1 *next;
size_
On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote:
I get want to define this struct in D:
```c
struct test1 {
struct test1 *prev;
struct test1 *next;
size_t v1;
size_t v2;
size_t v3;
char data[];
};
```
The easy way: put a slice there instead of a fake array and
a
On Friday, 30 July 2021 at 15:51:12 UTC, Tejas wrote:
On Friday, 30 July 2021 at 14:40:17 UTC, Paul Backus wrote:
On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote:
[...]
`char data[]` in the C struct is not a pointer, but actually a
[C99 flexible array member][1], and does not count to
On Fri, Jul 30, 2021 at 03:41:32PM +, Tejas via Digitalmars-d-learn wrote:
> On Friday, 30 July 2021 at 14:40:17 UTC, Paul Backus wrote:
[...]
> > ```d
> > struct test1 {
> > // member variables...
> >
> > char* data() {
> > return cast(char*) (&this + 1);
> > }
> > }
> > `
On Friday, 30 July 2021 at 14:40:17 UTC, Paul Backus wrote:
On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote:
[...]
`char data[]` in the C struct is not a pointer, but actually a
[C99 flexible array member][1], and does not count towards the
struct's `sizeof`.
D does not have flexibl
On Friday, 30 July 2021 at 14:40:17 UTC, Paul Backus wrote:
On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote:
[...]
`char data[]` in the C struct is not a pointer, but actually a
[C99 flexible array member][1], and does not count towards the
struct's `sizeof`.
D does not have flexibl
On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote:
I get want to define this struct in D:
```c
struct test1 {
struct test1 *prev;
struct test1 *next;
size_t v1;
size_t v2;
size_t v3;
char data[];
};
```
```d
struct test1 {
test1 *prev;
test1 *next;
size_
I get want to define this struct in D:
```c
struct test1 {
struct test1 *prev;
struct test1 *next;
size_t v1;
size_t v2;
size_t v3;
char data[];
};
```
```d
struct test1 {
test1 *prev;
test1 *next;
size_t v1;
size_t v2;
size_t v3;
char* data;
};
``