Re: anyway to debug nogc code with writeln?

2018-09-01 Thread Ali Çehreli via Digitalmars-d-learn
You can strip off any attribute with SetFunctionAttributes: import std.stdio; // Adapted from std.traits.SetFunctionAttributes documentation import std.traits; auto assumeNoGC(T)(T t) if (isFunctionPointer!T || isDelegate!T) { enum attrs = functionAttributes!T | FunctionAttribute.nogc;

anyway to debug nogc code with writeln?

2018-09-01 Thread aliak via Digitalmars-d-learn
I would like to debug a few things and need to insert print statements to figure things out. I thought that using debug print would be ok in nogc code? Seems it make the compiler infer f as not nogc though so this is basically unworkable unless I go through my entire source code and remove th

If I have an external test runner, can I get visibility up internal types only for version(unittest) ?

2018-09-01 Thread aliak via Digitalmars-d-learn
mypackage: internaltype.d package struct InternalType {} package template isInternalType(T) { ... } externaltype.d auto doStuff() { return InternalType(); } testfile.d @("Make sure under scenario X that InternalType is returned") unittest { static assert(isInternalType!(typeof(doS

Re: (u)byte calling char overload instead of int

2018-09-01 Thread Peter Alexander via Digitalmars-d-learn
On Saturday, 1 September 2018 at 17:17:37 UTC, puffi wrote: Hi, Is it by design that when calling functions with either ubyte or byte variables the char overload is called instead of the int (or generic) one? It seems this is by design. "If two or more functions have the same match level, th

Re: ldc2 crashes when trying to compile my app

2018-09-01 Thread Per Nordlöw via Digitalmars-d-learn
On Saturday, 1 September 2018 at 20:35:52 UTC, Per Nordlöw wrote: On Saturday, 1 September 2018 at 19:52:14 UTC, kinke wrote: `_Z7DtoLValP6DValue` may be suitable... Is this a C++-symbol? import core.demangle; demangle("_Z7DtoLValP6DValue") returns the same string... It's C++. Demangled v

Re: ldc2 crashes when trying to compile my app

2018-09-01 Thread Per Nordlöw via Digitalmars-d-learn
On Saturday, 1 September 2018 at 19:52:14 UTC, kinke wrote: `_Z7DtoLValP6DValue` may be suitable... Is this a C++-symbol? import core.demangle; demangle("_Z7DtoLValP6DValue") returns the same string...

Re: ldc2 crashes when trying to compile my app

2018-09-01 Thread kinke via Digitalmars-d-learn
On Saturday, 1 September 2018 at 19:35:53 UTC, Per Nordlöw wrote: What should I grep for when trying to Dustmite this? `_Z7DtoLValP6DValue` may be suitable. - I don't use dustmite and prefer manual minimization; e.g., by adding `-vv > bla.log` to the crashing commandline. The last lines in th

ldc2 crashes when trying to compile my app

2018-09-01 Thread Per Nordlöw via Digitalmars-d-learn
per:~/Work/knet] $ dub run --compiler=ldmd2 --build=release-nobounds The determined compiler type "ldc" doesn't match the expected type "dmd". This will probably result in build errors. WARNING: A deprecated branch based version specification is used for the dependency gmp-d. Please use numbered

Re: Cannot make sense of LLD linker error with ldc 1.11.0

2018-09-01 Thread kinke via Digitalmars-d-learn
On Saturday, 1 September 2018 at 18:46:32 UTC, Nordlöw wrote: Thanks! Is there usually only apps and not libs that are supposed to have linker flags like these? In this specific case, I'm not sure it's a good idea to set the linker in the dub config. Does it absolutely require gold, i.e., not

Re: Cannot make sense of LLD linker error with ldc 1.11.0

2018-09-01 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 30 August 2018 at 20:36:02 UTC, kinke wrote: On Thursday, 30 August 2018 at 19:41:38 UTC, Nordlöw wrote: I'm using the tar.xz for x64 Linux. Ok? You're explicitly adding `-link-internally` in your top-level dub.sdl: dflags "-link-internally" platform="linux-ldc" # use GNU gold

Re: Is this a good idea?

2018-09-01 Thread Dr.No via Digitalmars-d-learn
On Saturday, 1 September 2018 at 17:08:25 UTC, Peter Alexander wrote: On Saturday, 1 September 2018 at 16:20:11 UTC, Dr.No wrote: why move flush to outside the synchronized block? flush should be thread safe. In general, yiu want as little code as possible to run under the lock. Not that impo

(u)byte calling char overload instead of int

2018-09-01 Thread puffi via Digitalmars-d-learn
Hi, Is it by design that when calling functions with either ubyte or byte variables the char overload is called instead of the int (or generic) one?

Re: Is this a good idea?

2018-09-01 Thread Peter Alexander via Digitalmars-d-learn
On Saturday, 1 September 2018 at 16:20:11 UTC, Dr.No wrote: why move flush to outside the synchronized block? flush should be thread safe. In general, yiu want as little code as possible to run under the lock. Not that important though. trying out this approach I found to be ok except in som

Re: extern __gshared const(char)* symbol fails

2018-09-01 Thread Edgar Huckert via Digitalmars-d-learn
On Friday, 31 August 2018 at 17:50:17 UTC, Steven Schveighoffer wrote: ... When you use const char* in D, it's expecting a *pointer* to be stored at that address, not the data itself. So using it means segfault. The static array is the correct translation, even though it leaks implementation d

Re: Is this a good idea?

2018-09-01 Thread Dr.No via Digitalmars-d-learn
On Thursday, 30 August 2018 at 21:09:35 UTC, Peter Alexander wrote: On Thursday, 30 August 2018 at 19:59:17 UTC, Dr.No wrote: I would to process the current block in parallel but priting need to be theread-safe so I'm using foreach(x; parallel(arr)) { auto a = f(x); auto res = g(a);