C structs

2014-06-20 Thread Johann Lermer via Digitalmars-d-learn
Hi, I'm fiddling around with cairo (downloaded fromhttps://github.com/D-Programming-Deimos/cairo) and I stumbled over this problem: (file rectandmatrix.d) import deimos.cairo.cairo; void main () { cairo_rectangle_int_t rect; cairo_matrix_t matrix; } Compiling that with

Re: C structs

2014-06-20 Thread Johann Lermer via Digitalmars-d-learn
Agreed, but I assumed, that since all definitions in cairo.d are defined as extern (System), (same happens with extern (C), btw.), I would have expected, that D does not implicitly generate initialisation functions. So, why is there no init routine for the rectangle? There's only one for the

Re: Distinguish float and integer types from string

2019-03-11 Thread Johann Lermer via Digitalmars-d-learn
On Saturday, 9 March 2019 at 18:11:09 UTC, Jacob Shtokolov wrote: I tried to use std.conv.to and std.conv.parse, but found that they can't really do this. When I call `data.to!int`, the value of "123.45" will be converted to int! Are you sure? This here works for me: import std.stdio; import

Re: const pointers C vs. D

2020-02-06 Thread Johann Lermer via Digitalmars-d-learn
On Tuesday, 4 February 2020 at 10:17:39 UTC, Dennis wrote: C++ has a const system that is closer to D's than any other language, but it still has huge differences: Thanks, that clears it up a bit!

const pointers C vs. D

2020-02-04 Thread Johann Lermer via Digitalmars-d-learn
Hi, I'm just wondering about defining const pointers and if there's a difference in C and D. in C, this works: const char* text = "Hello"; text = "world"; but in D it doesn't, because the char* is const. Ff I would like tho have the same behaviour in D as in C, I need to write: const

Re: How to implement Canceleable spawn() from parent

2020-06-29 Thread Johann Lermer via Digitalmars-d-learn
I'm doing this in an X11 application in order to send a timer event every 100 milliseconds to the main event queue. class Application { shared private bool s_tick; void clock_task (shared X11.Display* disp, X11.Atom atom, X11.Window win) { for (;;) { try {

Re: sending the address of a struct

2020-09-06 Thread Johann Lermer via Digitalmars-d-learn
On Sunday, 6 September 2020 at 11:10:14 UTC, Simen Kjærås wrote: auto e = receiveOnly!(shared(Env)*); Oh, thanks. Seems, that I just missed that bit with the pranetheses.

sending the address of a struct

2020-09-06 Thread Johann Lermer via Digitalmars-d-learn
Hi, I have a struct in a separate thread and want to pass it's address back to the main thread. This is how I think it should work: import std.concurrency; struct Env {} void run () { shared Env env; ownerTid.send (); for (;;) {} } void main () { spawn ();