Re: Memory management by interfacing C/C++

2019-04-29 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Monday, 29 April 2019 at 14:38:54 UTC, 9il wrote: On Saturday, 27 April 2019 at 22:25:58 UTC, Ferhat Kurtulmuş wrote: [...] Hello Ferhat, You can use RCArray!T or Slice!(RCI!T) [1, 2] as common thread safe @nogc types for D and C++ code. See also integration C++ example [3] and C++

Re: Logging best practices

2019-04-29 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Sat, Apr 27, 2019 at 2:55 AM Andre Pany via Digitalmars-d-learn wrote: > > On Thursday, 25 April 2019 at 10:33:00 UTC, Vladimirs Nordholm > wrote: > > Hello. > > > > Is there a current "Best Practices" for logging in D? > > > > For the actual logging, I know of `std.experimental.logger`. > >

Re: srand time error uint/long

2019-04-29 Thread number via Digitalmars-d-learn
On Monday, 29 April 2019 at 14:39:29 UTC, rikki cattermole wrote: float f = uniform01(); Its already initialized on module load. If you do want to custom seed it, you'll probably want to cast the seed to uint instead and have your own instance of the random number generator. On Monday, 29

Re: srand time error uint/long

2019-04-29 Thread Paul Backus via Digitalmars-d-learn
On Monday, 29 April 2019 at 14:36:49 UTC, number wrote: And how to use the d libs instead? is this the way to go? ``` Random rnd = Random(Clock.currTime().second); uniform01(rnd); //(or whatever) ``` https://dlang.org/phobos/std_random.html#unpredictableSeed

srand time error uint/long

2019-04-29 Thread number via Digitalmars-d-learn
How to call srand() with time()? ``` void main() { import core.stdc.stdlib : rand, srand; import core.stdc.time : time; srand(time(null)); } ``` Error: function core.stdc.stdlib.srand(uint seed) is not callable using argument types (long) cannot pass argument time(null) of type

Re: Memory management by interfacing C/C++

2019-04-29 Thread 9il via Digitalmars-d-learn
On Saturday, 27 April 2019 at 22:25:58 UTC, Ferhat Kurtulmuş wrote: Hi, I am wrapping some C++ code for my personal project (opencvd), and I am creating so many array pointers at cpp side and containing them in structs. I want to learn if I am leaking memory like crazy, although I am not

Re: srand time error uint/long

2019-04-29 Thread rikki cattermole via Digitalmars-d-learn
float f = uniform01(); Its already initialized on module load. If you do want to custom seed it, you'll probably want to cast the seed to uint instead and have your own instance of the random number generator.

Re: Memory management by interfacing C/C++

2019-04-29 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Monday, 29 April 2019 at 00:53:34 UTC, Paul Backus wrote: On Sunday, 28 April 2019 at 23:10:24 UTC, Ferhat Kurtulmuş wrote: You are right. I am rewriting the things using mallocs, and will use core.stdc.stdlib.free on d side. I am not sure if I can use core.stdc.stdlib.free to destroy

Re: DLL creation fails with undefined symbol error

2019-04-29 Thread Kagamin via Digitalmars-d-learn
fwrite, fputc - that's missing C library.