Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Dsby via Digitalmars-d-learn
On Sunday, 31 January 2016 at 05:29:06 UTC, Mike Parker wrote: On Sunday, 31 January 2016 at 05:28:02 UTC, Mike Parker wrote: need to call core.thread.attach_this [1] so that runtime is Sorry, that's core.thread.thread_attachThis ok。thanks.

Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 31 January 2016 at 05:28:02 UTC, Mike Parker wrote: need to call core.thread.attach_this [1] so that runtime is Sorry, that's core.thread.thread_attachThis

Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 31 January 2016 at 03:45:01 UTC, Dsby wrote: Thanks, if I use the D dylib,I should run " rt_init(); " in every thread which i used the D dylib? No. rt_init only needs to be called once for the process. You need to call core.thread.attach_this [1] so that runtime is aware of your

Re: C Macro deeper meaning?

2016-01-30 Thread Andrew Edwards via Digitalmars-d-learn
On Sunday, 31 January 2016 at 03:13:46 UTC, Adam D. Ruppe wrote: On Sunday, 31 January 2016 at 02:58:28 UTC, Andrew Edwards wrote: But it cannot be that simple, so what am I missing? I'm guessing the macro was there in C to silence compiler warnings about not using a return value. So I think

Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Dsby via Digitalmars-d-learn
On Saturday, 30 January 2016 at 16:06:37 UTC, Chris Wright wrote: On Sat, 30 Jan 2016 14:41:18 +, Dsby wrote: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop? The GC will stop every thread it knows about. If you have a C++ thread that

Re: C Macro deeper meaning?

2016-01-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 31 January 2016 at 02:58:28 UTC, Andrew Edwards wrote: But it cannot be that simple, so what am I missing? I'm guessing the macro was there in C to silence compiler warnings about not using a return value. So I think your translation is ok: NOTUSED(somefunction()); still cal

C Macro deeper meaning?

2016-01-30 Thread Andrew Edwards via Digitalmars-d-learn
If I understand correctly, this piece of code: enum NOTUSED(v) do { (void)(1 ? (void)0 : ( (void)(v) ) ); } while(0) can be converted to the following in D: void notUsed(T)(T v) { return cast(void)0; }; since it always returns cast(void)0 regardless of the input. But it cannot be tha

Re: UTF-16 endianess

2016-01-30 Thread Marek Janukowicz via Digitalmars-d-learn
On Fri, 29 Jan 2016 18:58:17 -0500, Steven Schveighoffer wrote: >>> Note the version identifiers BigEndian and LittleEndian can be used to >>> compile the correct code. >> >> This solution is of no use to me as I don't want to change the endianess in >> general. > > What I mean is that you can anno

Re: How do you initialize a class instance which has static storage within another class?

2016-01-30 Thread Chris Wright via Digitalmars-d-learn
On Sat, 30 Jan 2016 22:02:10 +, Enjoys Math wrote: > On Saturday, 30 January 2016 at 21:52:20 UTC, Enjoys Math wrote: >> >> class A { static B b; } class B {} >> >> doing b = new B() does NOT work. >> >> Nor could I create a this() {} at module level > > More info: > > B : A > > so I can't

Re: How do you initialize a class instance which has static storage within another class?

2016-01-30 Thread Enjoys Math via Digitalmars-d-learn
On Saturday, 30 January 2016 at 21:52:20 UTC, Enjoys Math wrote: class A { static B b; } class B {} doing b = new B() does NOT work. Nor could I create a this() {} at module level More info: B : A so I can't do class A { this () { if (b is null) { b = new B(); } } } Sin

Re: How do you initialize a class instance which has static storage within another class?

2016-01-30 Thread anonymous via Digitalmars-d-learn
On 30.01.2016 22:52, Enjoys Math wrote: class A { static B b; } class B {} doing b = new B() does NOT work. Nor could I create a this() {} at module level It works when you make b const/immutable: class A {static immutable B b = new B;} class B {} If you want/need b to be mutable, you can

How do you initialize a class instance which has static storage within another class?

2016-01-30 Thread Enjoys Math via Digitalmars-d-learn
class A { static B b; } class B {} doing b = new B() does NOT work. Nor could I create a this() {} at module level

Re: Access Violation in @safe Code

2016-01-30 Thread Matt Elkins via Digitalmars-d-learn
On Saturday, 30 January 2016 at 13:37:43 UTC, Kagamin wrote: Alias templates require stack pointer, init probably has it set to null. Try this: FooType foo = FooType(); Yes, that fixed it. Interesting.

Re: Pipe one shell command into another

2016-01-30 Thread Andrew via Digitalmars-d-learn
On Saturday, 30 January 2016 at 15:57:49 UTC, Griffon26 wrote: On Saturday, 30 January 2016 at 15:12:26 UTC, Andrew wrote: foreach(line; pipesLs.stdout.byLine) pipesSort.stdin.writeln(line); Because you write sort's input first and read its output later, it might end up blocking if ls g

Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Chris Wright via Digitalmars-d-learn
On Sat, 30 Jan 2016 14:41:18 +, Dsby wrote: > Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) > run. will not my program stop? The GC will stop every thread it knows about. If you have a C++ thread that you want to run while the GC is running, you can get that by not

Re: Pipe one shell command into another

2016-01-30 Thread Griffon26 via Digitalmars-d-learn
On Saturday, 30 January 2016 at 15:12:26 UTC, Andrew wrote: foreach(line; pipesLs.stdout.byLine) pipesSort.stdin.writeln(line); Because you write sort's input first and read its output later, it might end up blocking if ls generates too much data. The output pipe of sort will fill up, c

Pipe one shell command into another

2016-01-30 Thread Andrew via Digitalmars-d-learn
Hi, I'd like to run a shell command which involves piping one thing into another and then processes the output line by line, i.e. something like "ls -l | sort -k5,5n" What I've come up so far with is: import std.process; import std.stdio; void main(){ auto pipesLs = pipeProcess(["ls", "-l

Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Dsby via Digitalmars-d-learn
Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop? My lib.so is writed in D, and I use the GC.and then I am used the dll in my program that is writed in C++. I want to know when the GC(in lib.so's runtime) start runing, will my program be stop

Re: Access Violation in @safe Code

2016-01-30 Thread Kagamin via Digitalmars-d-learn
Alias templates require stack pointer, init probably has it set to null. Try this: FooType foo = FooType();

Re: is(some template instantiation) is true, but the actual instantiation fails

2016-01-30 Thread Adrian Matoga via Digitalmars-d-learn
On Saturday, 30 January 2016 at 00:16:21 UTC, Ali Çehreli wrote: > https://issues.dlang.org/show_bug.cgi?id=15623 As I noted on the bug report, they are work when moved from module scope to inside a function (e.g. main()). At least there's that workaround... Ali Thanks a lot! Now I can con

Re: is(some template instantiation) is true, but the actual instantiation fails

2016-01-30 Thread Adrian Matoga via Digitalmars-d-learn
On Friday, 29 January 2016 at 23:44:56 UTC, Basile B. wrote: Haven't you seen my answer about constraint ? If you put a constraint on your function template then invalid instantiations are rejected. I mean... this language feature is not just ornamental... What do you think constraints are u

Re: Dub packages: Best practices for windows support

2016-01-30 Thread Guillaume Piolat via Digitalmars-d-learn
On Saturday, 30 January 2016 at 01:17:13 UTC, Mike Parker wrote: On Friday, 29 January 2016 at 19:46:40 UTC, Johannes Pfau wrote: Now on windows, things are more complicated. First of all, I can't seem to simply use "libs": ["foo"] as the linker won't find the C import .lib file. Then apparent

Re: Dub packages: Best practices for windows support

2016-01-30 Thread Johannes Pfau via Digitalmars-d-learn
Am Sat, 30 Jan 2016 01:17:13 + schrieb Mike Parker : > On Friday, 29 January 2016 at 19:46:40 UTC, Johannes Pfau wrote: > > > Now on windows, things are more complicated. First of all, I > > can't seem > > to simply use "libs": ["foo"] as the linker won't find the C > > import .lib file. The

Re: d plugin for Intelij Idea debuging support

2016-01-30 Thread ZombineDev via Digitalmars-d-learn
On Friday, 29 January 2016 at 12:00:25 UTC, Pavel wrote: Hello! Is there any debuging support for Intelij Idea's D plugin? Thanks! Currently only XamarinStudio/MonoDevelop and DlangIDE allow debugging on Linux through GDB. On Windows VisaulD provides debugging support for Visual Studio.

Re: Why is it a memory ERRO.

2016-01-30 Thread ZombineDev via Digitalmars-d-learn
On Saturday, 30 January 2016 at 05:50:33 UTC, Dsby wrote: Ok.Thank you. and i want to know how to know when the GC start runing? See also http://dlang.org/phobos/core_memory