June 17, 2021 Learn » Re: Can not get struct member addresses at compile time | |||
|---|---|---|---|
| |||
...my first example:
```d
struct Foo{
int bar;
}
__gshared Foo foo;
void *fooptr = &foo;
```
This... | |||
June 17, 2021 General » Re: Simplification of @trusted | |||
|---|---|---|---|
| |||
...Foo{
int test()@safe{
return 1;
}
}
struct Bar{
int test()@system{
return 2;
}
}
void system... | |||
June 16, 2021 Learn » Re: Can not get struct member addresses at compile time | |||
|---|---|---|---|
| |||
...0x55fbd8292030
printf("Address of bar: %p\n", barptr); //Address of bar: 0x55fbd8292030
printf("Address of... | |||
June 16, 2021 Learn » Re: Can not get struct member addresses at compile time | |||
|---|---|---|---|
| |||
...bar;
> }
>
> void* membaddr(void *ptr, ulong offset){
> return ptr+offset;
> }
>
> __gshared Foo foo;
> void* bar... | |||
June 16, 2021 Learn » Re: Can not get struct member addresses at compile time | |||
|---|---|---|---|
| |||
...c
struct Foo{
char bar;
};
struct Foo foo;
void *ptr = &foo.bar; //compiles, links and... | |||
June 16, 2021 Learn » Re: Can not get struct member addresses at compile time | |||
|---|---|---|---|
| |||
...bar;
}
void* membaddr(void *ptr, ulong offset){
return ptr+offset;
}
__gshared Foo foo;
void* bar... | |||
June 16, 2021 Learn » Re: Can not get struct member addresses at compile time | |||
|---|---|---|---|
| |||
...foo.addrOf.bar); writeln(foo.addrOf.i); // Alternative syntax writeln(addrOf(foo).bar); writeln(addrOf... | |||
June 16, 2021 General » Re: Simplification of @trusted | |||
|---|---|---|---|
| |||
...the pointer within the @trusted block and `bar` assigns it outside the @trusted block. It... | |||
June 16, 2021 Learn » Re: Can not get struct member addresses at compile time | |||
|---|---|---|---|
| |||
...initialize() { bar = &foo.bar; }
void main()
{
*(cast(ubyte*)bar) = 10;
printf("%d", foo.bar);
}
```
https... | |||
June 16, 2021 Learn » Can not get struct member addresses at compile time | |||
|---|---|---|---|
| |||
...Foo{
ubyte bar;
}
__gshared Foo foo;
void* baz = \&foo; //works
void* bar = \&foo.bar; //Error... | |||
Copyright © 1999-2021 by the D Language Foundation