On 6/16/21 3:27 PM, Doeme wrote:
On Wednesday, 16 June 2021 at 22:16:54 UTC, H. S. Teoh wrote:
The compiler does not (and cannot) know. But the runtime dynamic
linker can, and does. The two are bridged by the compiler emitting a
relocatable symbol for the address of the global variable, with
On Wednesday, 16 June 2021 at 20:54:07 UTC, H. S. Teoh wrote:
On Wed, Jun 16, 2021 at 08:44:46PM +, Brian via
Digitalmars-d-learn wrote: [...]
struct item
{
string name;
int type;
};
[...]
new_item = { "item1", 1 };
The {...} initializer syntax is only available in va
On Wednesday, 16 June 2021 at 22:16:54 UTC, H. S. Teoh wrote:
The compiler does not (and cannot) know. But the runtime
dynamic linker can, and does. The two are bridged by the
compiler emitting a relocatable symbol for the address of the
global variable, with a table of relocations (offsets i
On Wed, Jun 16, 2021 at 02:42:41PM -0700, Ali Çehreli via Digitalmars-d-learn
wrote:
[...]
> Actually, it is news to me that the compiler can know (determine?) the
> address of a global variable.
[...]
The compiler does not (and cannot) know. But the runtime dynamic linker
can, and does. The tw
On Wednesday, 16 June 2021 at 21:42:41 UTC, Ali Çehreli wrote:
On 6/16/21 8:47 AM, Doeme wrote:
> On Wednesday, 16 June 2021 at 13:36:07 UTC, Ali Çehreli wrote:
>> On 6/16/21 2:27 AM, Doeme wrote:
>>
>> > How does one get the address of a struct member?
>>
>> Here is an experiment with offsetof
On 6/16/21 8:47 AM, Doeme wrote:
> On Wednesday, 16 June 2021 at 13:36:07 UTC, Ali Çehreli wrote:
>> On 6/16/21 2:27 AM, Doeme wrote:
>>
>> > How does one get the address of a struct member?
>>
>> Here is an experiment with offsetof and opDispatch:
>
> Cool stuff!
> I actually tried a very simila
On Wed, Jun 16, 2021 at 08:44:46PM +, Brian via Digitalmars-d-learn wrote:
[...]
> struct item
> {
> string name;
> int type;
> };
[...]
> new_item = { "item1", 1 };
The {...} initializer syntax is only available in variable declarations,
e.g.:
item i = { "item1",
On Wednesday, 16 June 2021 at 06:28:40 UTC, guest wrote:
STR:
1. open
http://forum.dlang.org/static-bundle/637528586548394375/dlang.org/js/dlang.js+js/dfeed.js
2. press reload (F5 or ctrl+R)
Noticed this too and fixed it a bit ago. It was sending 500
instead of 304, so actually the only way
Hello all --
I have a question about assigning to structs.
I want to be able to create an array of structs that may contain
different contents depending on user input. I have reduced the
test case down.
The following fails to compile:
```d
import std.stdio;
struct item
{
string name;
On Wednesday, 16 June 2021 at 05:48:21 UTC, VitaliiY wrote:
On Tuesday, 15 June 2021 at 12:39:40 UTC, Dennis wrote:
On Tuesday, 15 June 2021 at 12:18:26 UTC, VitaliiY wrote:
[...]
```D
enum string ADDBITS(string a, string b) = `
{
bitbuffer = (bitbuffer<<(`~a~`))|((`~b~`)&((1<<`~a~`)-1));
On Wednesday, 16 June 2021 at 16:27:13 UTC, Dennis wrote:
On Wednesday, 16 June 2021 at 14:38:10 UTC, jfondren wrote:
What do I change to
1. a script like this that uses hostname
2. the hostname module
so that both can be built with -betterC when and only when
the script is using -betterC?
Th
On Wednesday, 16 June 2021 at 16:27:13 UTC, Dennis wrote:
It has to be a linker error, dmd cannot know at the time of
compiling project A how project B is going to be compiled and
vice versa.
Well I suppose you could use a specific dub configuration, maybe
giving 'hostname' a targetType "sour
On Wednesday, 16 June 2021 at 14:38:10 UTC, jfondren wrote:
What do I change to
1. a script like this that uses hostname
2. the hostname module
so that both can be built with -betterC when and only when
the script is using -betterC?
That's currently the situation: you can only build when both
On Wednesday, 16 June 2021 at 11:56:31 UTC, Mike Parker wrote:
https://dlang.org/spec/pragma.html#crtctor
Very interesting, thanks for the hint! This is definitely a
viable solution, though if there's a way to let the linker
determine the pointer address, that'd be even better.
In C, it's a
On Wednesday, 16 June 2021 at 13:36:07 UTC, Ali Çehreli wrote:
On 6/16/21 2:27 AM, Doeme wrote:
> How does one get the address of a struct member?
Here is an experiment with offsetof and opDispatch:
Cool stuff!
I actually tried a very similar approach once, but it did not
work out, since the
On Wednesday, 16 June 2021 at 14:21:40 UTC, jfondren wrote:
Why isn't this linking?
OK, with verbose commands I see that libhostname.a is built
without -betterC
So that's why this fails to link.
What do I change to
1. a script like this that uses hostname
2. the hostname module
so that bo
On Wednesday, 16 June 2021 at 13:26:43 UTC, jfondren wrote:
Is this a bug?
Probably. Please file an issue if there isn't one already:
https://issues.dlang.org/
Here's a complete script that you can run right now, using
a dub module that I just updated:
```d
#!/usr/bin/env dub
/+ dub.sdl:
dependency "hostname" version="~>0.1.1"
buildOptions "betterC"
+/
extern(C) void main() {
import hostname : hostnamez;
import core.stdc.stdio : printf;
On 6/16/21 2:27 AM, Doeme wrote:
> How does one get the address of a struct member?
Here is an experiment with offsetof and opDispatch:
struct Foo{
ubyte bar;
int i;
}
auto addrOf(T)(ref T t) {
static struct AddrOf {
void * origin;
auto opDispatch(string member)() {
return or
On Wednesday, 16 June 2021 at 11:56:31 UTC, Mike Parker wrote:
https://dlang.org/spec/pragma.html#crtctor
"as a simple replacement for shared static this in betterC mode"
Cool.
However,
```d
immutable int example;
version(D_BetterC) {
pragma(crt_constructor) extern(C) void initialize() {
On Wednesday, 16 June 2021 at 09:27:25 UTC, Doeme wrote:
Is there an alternative to get to this point? Static module
initializers are not really an option, since the whole thing
should be -betterC.
```D
import core.stdc.stdio;
struct Foo{
ubyte bar;
}
__gshared Foo foo;
void* baz = &foo;
Hi!
I'm currently investigating why I can not take the address of a
static struct-element at compile time (afaik the linker should be
able to resolve this, and doing the identical thing in C works...)
```d
struct Foo{
ubyte bar;
}
__gshared Foo foo;
void* baz = \&foo; //works
void* ba
On Wednesday, 16 June 2021 at 06:29:21 UTC, z wrote:
On Tuesday, 15 June 2021 at 06:39:24 UTC, seany wrote:
...
This is the best I could do: https://run.dlang.io/is/dm8LBP
For some reason, LDC refuses to vectorize or even just unroll
the nonparallel version, and more than one `parallel` corru
On Wednesday, 16 June 2021 at 02:46:36 UTC, cc wrote:
I can't seem to get it to work as a return type, but
interestingly it does work as an out/pass by ref parameter.
Probably for returning the struct it needs some allocation
directive in C# but I'm not sure. Maybe C# also tries something
to
24 matches
Mail list logo