Conditional compilation for debug/release

2015-04-06 Thread Johan Engelen via Digitalmars-d-learn
How do conditionally compile code for either release (-release) or debug (-debug)? Something like this: version(Debug) { pragma(lib, libcmtd.lib); } else { pragma(lib, libcmt.lib); } In the documentation [1], I don't see any predefined version identifiers for this purpose. Thanks,

Re: Conditional compilation for debug/release

2015-04-06 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 6 April 2015 at 15:24:53 UTC, Namespace wrote: On Monday, 6 April 2015 at 15:15:48 UTC, Johan Engelen wrote: On Monday, 6 April 2015 at 14:55:58 UTC, Namespace wrote: debug { pragma(lib, libcmtd.lib); } else { pragma(lib, libcmt.lib); } Thanks for the quick reply! Worth

Re: Conditional compilation for debug/release

2015-04-06 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 6 April 2015 at 14:55:58 UTC, Namespace wrote: debug { pragma(lib, libcmtd.lib); } else { pragma(lib, libcmt.lib); } Thanks for the quick reply! Worth adding an example like that to http://dlang.org/version.html ?

Select value from list, indexed by a type

2015-07-28 Thread Johan Engelen via Digitalmars-d-learn
Hi all, I am wondering if there is any Phobos functionality for indexing into a list using a type. What I mean is something like: assert( somethingie!(float, float, double, real)(1, 22, 333) == 1 ); assert( somethingie!(double, float, double, real)(1, 22, 333) == 22 ); assert(

"final" as function parameter attribute?

2015-11-21 Thread Johan Engelen via Digitalmars-d-learn
On http://dlang.org/function.html, I read that "final" is a valid attribute/storage class for function parameters: InOutX: auto TypeCtor final <-- ?? in lazy out ref scope This looks like a documentation error, but perhaps it's not. I hope someone can explain

Re: "final" as function parameter attribute?

2015-11-22 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 22 November 2015 at 00:21:29 UTC, Jonathan M Davis wrote: Neither auto nor final is valid on a function parameter, so either the grammar is wrong, or InOutX is not used for function parameters. But looking at that page, I'd have to spend a fair bit of time working through it to

Re: Recommended coding convention for combining unix and windows code ?

2016-06-07 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 15:33:57 UTC, chmike wrote: or should I do it the C way with multiple embedded static if... In your example, `version` would also work instead of `static if`. I would not copy much code needlessly, and go with the embedded version/static ifs. - Johan

Re: What's up with GDC?

2016-06-10 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 10 June 2016 at 19:37:13 UTC, Joerg Joergonson wrote: arm-linux-genuabi? arm-linux-gnueableihfqueridsofeyfh? aifh-fkeif-f-fdsskjhfkjfafaa? Rofl! and ldc requires building from sources(actually I didn't have too much trouble with installing it but it doesn't work

Re: Alias this member shadowed by imported function identifier?

2016-05-28 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 27 May 2016 at 17:00:04 UTC, Steven Schveighoffer wrote: Now, the question here is, when does alias this kick in? I would say it should follow alias this before looking outside the module, so I say it's a bug. https://issues.dlang.org/show_bug.cgi?id=16086

Re: What's up with GDC?

2016-06-11 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 11 June 2016 at 08:48:42 UTC, Mike Parker wrote: [... a lot ...] This looks like a nice writeup Mike, could you get this on the Wiki or somewhere more permanent where people can find it? -Johan

Re: What's up with GDC?

2016-06-12 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 12 June 2016 at 04:19:33 UTC, Joerg Joergonson wrote: So ldc parses things differently than dmd... I imagine this is a bug! That, or you are comparing different D language versions. The D language is evolving: different DMD compiler versions may treat the same code differently.

Re: What's up with GDC?

2016-06-12 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 12 June 2016 at 04:19:33 UTC, Joerg Joergonson wrote: Here are the versions The one that isn't working: LDC - the LLVM D compiler (30b1ed): based on DMD v2.071.1 and LLVM 3.9.0git-d06ea8a built with LDC - the LLVM D compiler (1.0.0) Default target: x86_64-pc-windows-msvc

Re: What's up with GDC?

2016-06-12 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 12 June 2016 at 03:11:14 UTC, Mike Parker wrote: On Sunday, 12 June 2016 at 01:51:05 UTC, Joerg Joergonson wrote: DMD works fine BTW. GDC and LDC should be a drop in replacement. Not a totally new setup that has it's own set of problems. I'm sure I'm not the only one put off by

Re: Is there any overhead iterating over a pointer using a slice?

2016-05-31 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 31 May 2016 at 18:55:18 UTC, Gary Willoughby wrote: If I have a pointer and iterate over it using a slice, like this: T* foo = foreach (element; foo[0 .. length]) { ... } Is there any overhead compared with pointer arithmetic in

Alias this member shadowed by imported function identifier?

2016-05-27 Thread Johan Engelen via Digitalmars-d-learn
The following code compiles with DMD 2.070, but not with 2.071: ``` module mod; import std.range; struct S { struct Inner { int unique_identifier_name; int tail; } Inner inner; alias inner this; auto works() { return unique_identifier_name;

Re: Can I get a more in-depth guide about the inline assembler?

2016-06-02 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 23:23:49 UTC, ZILtoid1991 wrote: Here's the assembly code for my alpha-blending routine: Could you also paste the D version of your code? Perhaps the compiler (LDC, GDC) will generate similarly vectorized code that is inlinable, etc. -Johan

Re: Default initialization of structs?

2016-06-17 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 17 June 2016 at 10:50:55 UTC, Gary Willoughby wrote: I have a struct where I need to perform default initialization of some members but the compiler doesn't allow to define a default constructor which allow optional arguments. This is a fairly recent change (2.068->2.069 or 2.070),

How to get access to Voldemort / private thingies

2016-06-17 Thread Johan Engelen via Digitalmars-d-learn
Hi all, Is there another way to get access to Voldemort class methods, or private class members, other than using "pragma(mangle, ...)" on user symbols? Example code: In library, and _should not_ be changed : ``` Object getObject() { class Vold : Object { int store;

Re: How to get access to Voldemort / private thingies

2016-06-18 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 17 June 2016 at 21:07:31 UTC, cy wrote: On Friday, 17 June 2016 at 19:49:18 UTC, Johan Engelen wrote: Hi all, Is there another way to get access to Voldemort class methods, or private class members, other than using [... snip ...] Because of the guarantee that you can link to

Re: How to get access to Voldemort / private thingies

2016-06-18 Thread Johan Engelen via Digitalmars-d-learn
Someone figured out how to do it and put it in std.traits! ;-) Example: ``` import std.stdio; import core.thread; import std.traits; void main() { Fields!Thread[11] a; writeln(typeid(a)); } ``` This prints "core.thread.Thread.Context" , which is a private struct type of

Re: How to get access to Voldemort / private thingies

2016-06-18 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 18 June 2016 at 17:50:51 UTC, cy wrote: On Saturday, 18 June 2016 at 08:41:30 UTC, Johan Engelen wrote: Without going in too much detail, the problem is that I am not linking to opaque .o files. The problem is the compiler has to assume you *might* be linking to opaque .o files,

Re: issue porting C++/glm/openGL to D/gl3n/openGL

2016-01-10 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 10 January 2016 at 10:35:34 UTC, Johan Engelen wrote: It's pretty strange that there is no "translate" method... Didn't see it in the online docs, but in the source there is the "translate" method that you should use.

Re: issue porting C++/glm/openGL to D/gl3n/openGL

2016-01-10 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 10 January 2016 at 02:51:57 UTC, WhatMeWorry wrote: I thought just swapping the order would fix things: transform = transform.rotate(0.78539, vec3(0.0f, 0.0f, 1.0f)); transform = transform.translation(vec3(0.5f, -0.5f, 0.0f)); but now the square is moved to the lower right corner

Conditional compilation inside an array initializer

2016-01-18 Thread Johan Engelen via Digitalmars-d-learn
Is it possible to do conditional compilation inside an array initializer? Something like this: int[] inttable = [ 1, 4, version(smth) { // <--- does not compile 5, 6, } 8, 1345 ]; (real world case:

Re: Issues

2016-02-23 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 22 February 2016 at 23:21:28 UTC, Jonathan M Davis wrote: Well, if you'll notice th list of resolved issues is going up way faster than the list of new issues. (To put some oil on the fire:) But the number of new issues /is/ going up. I.e. the number of resolved issues is going

Define "createXXX" functions for the constructors of class XXX

2016-01-23 Thread Johan Engelen via Digitalmars-d-learn
Hi all, While trying to interface C++ and D, I have to new a few D objects in C++ code. I am doing this using a D function: "XXX createXXX(...) { return new XXX(...); }". I am sure there must be some great way to automatically generate these creator functions, but I don't know how to do it.

Re: Define "createXXX" functions for the constructors of class XXX

2016-01-24 Thread Johan Engelen via Digitalmars-d-learn
Thanks for the rapid explanations and code! Such a great forum :-) Much obliged, Johan

Re: Define "createXXX" functions for the constructors of class XXX

2016-01-24 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 23 January 2016 at 19:42:29 UTC, Johan Engelen wrote: Hi all, While trying to interface C++ and D, I have to new a few D objects in C++ code. I am doing this using a D function: "XXX createXXX(...) { return new XXX(...); }". An easier way for trivial constructors (note

Re: Solution to "statement is not reachable" depending on template variables?

2016-03-18 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 11:22:02 UTC, rikki cattermole wrote: Change those static if's to just plain old ifs. But then this wouldn't compile, would it? ``` static if(__traits(compiles, __traits(getMember, a, "b"))) { return a.b; } ``` (real code, I am not making this up) Imagine

Re: size_t index=-1;

2016-03-19 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 22:07:39 UTC, Anonymouse wrote: size_t pos = "banana".indexOf("c"); if (pos > 0) { Although I also think it makes sense to warn (in specific cases) about mixed-sign comparisons, the example you give here does nothing that we can warn about. It is a comparison

Re: Solution to "statement is not reachable" depending on template variables?

2016-03-19 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 17:34:13 UTC, Steven Schveighoffer wrote: On 3/16/16 7:18 AM, Johan Engelen wrote: Hi all, I've found discussions, but not an actual "recommended" solution for the problem of "statement is not reachable" warnings in templates with early returns, e.g.: ```

Get VTable pointer as a constant

2016-04-07 Thread Johan Engelen via Digitalmars-d-learn
I am trying to get the vtable pointer as a constant (!). I've found auto vptr = typeid(A).vtbl.ptr gets me the pointer, but because TypeInfo is not immutable (another forum thread), this will read the pointer from memory instead of loading a direct value. Does anybody know how to get the

Re: Get third part of front-end version number

2016-04-05 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 5 April 2016 at 18:01:05 UTC, Nick Sabalausky wrote: These days, DMD/DMDFE version numbers are three parts, ex: 2.070.1. I can get the first two via std.compiler.version_major and std.compiler.version_minor. Is there a way to get the third part? I know I can "dmd --help | grep

Re: Get VTable pointer as a constant

2016-04-08 Thread Johan Engelen via Digitalmars-d-learn
On Thursday, 7 April 2016 at 20:49:40 UTC, Adam D. Ruppe wrote: On Thursday, 7 April 2016 at 20:43:04 UTC, Johan Engelen wrote: Does anybody know how to get the class's vtable pointer without doing a memory read? I don't think you can... why do you want it though? I have implemented PGO

Solution to "statement is not reachable" depending on template variables?

2016-03-20 Thread Johan Engelen via Digitalmars-d-learn
Hi all, I've found discussions, but not an actual "recommended" solution for the problem of "statement is not reachable" warnings in templates with early returns, e.g.: ``` bool nobool(T...)() { foreach (i, U; T) { static if (is(U == bool)) { return false; }

Re: pass a struct by value/ref and size of the struct

2016-03-22 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 21 March 2016 at 23:31:06 UTC, ref2401 wrote: I have got a plenty of structs in my project. Their size varies from 12 bytes to 128 bytes. Is there a rule of thumb that states which structs I pass by value and which I should pass by reference due to their size? Note that the

Re: pass a struct by value/ref and size of the struct

2016-03-22 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 22 March 2016 at 07:35:49 UTC, ZombineDev wrote: If the object is larger than the size of a register on the target machine, it is implicitly passed by ref (i.e. struct fields are accessed by offset from the stack pointer). (Oops, sorry ZombineDev, should've read your reply

Re: Solution to "statement is not reachable" depending on template variables?

2016-03-19 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 11:47:35 UTC, QAston wrote: import std.meta; template isBool(U)() = is(U == bool); static if (!allSatisfy!(isBool, T)) { return true; // no longer emits a warning } Something like this should work. Thanks, but: On Wednesday, 16 March 2016 at 11:18:36 UTC,

Re: Warning: statement is not reachable

2016-03-02 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 07:42:09 UTC, Tamas wrote: Thanks, fixing this single issue solved the compiler crash too. Did the compiler crash? Or just exit? (a crash would still be a bug)

Re: Solution to "statement is not reachable" depending on template variables?

2016-04-01 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 1 April 2016 at 01:21:32 UTC, Walter Bright wrote: On 3/16/2016 4:18 AM, Johan Engelen wrote: I've found discussions, but not an actual "recommended" solution for the problem of "statement is not reachable" warnings in templates with early returns, e.g.: ``` bool nobool(T...)()

Re: mutable keyword

2016-05-20 Thread Johan Engelen via Digitalmars-d-learn
On Thursday, 19 May 2016 at 23:21:14 UTC, Jonathan M Davis wrote: No. D's const and immutable provide no backdoors. Rather, they provide strong guarantees. So, if a variable is const, then it cannot be mutated (even internally) except via a mutable reference to the same data. The "even

Re: to auto or not to auto ( in foreach )

2016-07-18 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 16 July 2016 at 22:05:49 UTC, ketmar wrote: `foreach (v; rng)` looks like `foreach` is *reusing* *existing* *variable*. +1

Re: Local fixed sized arrays

2016-06-30 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 27 June 2016 at 21:58:04 UTC, "Smoke" Adams wrote: I'm in need of a way to create a local array that isn't GC'ed. It must be dynamic in the sense of setting the size at compile time but it will be used only in scope and only on structs. `alloca` is made for that purpose.

Re: Is there anything fundamentally wrong with this code?

2017-02-03 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 3 February 2017 at 17:20:43 UTC, WhatMeWorry wrote: -file post_processor.d -- module post_processor; class PostProcessor { ... GLuint FBO; } -file game.d --- module game; PostProcessor postProc; //

Returning the address of a reference return value in @safe code - 2.072 regression?

2017-02-20 Thread Johan Engelen via Digitalmars-d-learn
This code compiles with 2.071, but not with 2.072 nor 2.073: ``` struct S { int i; auto ref foo() @safe { return i; } auto bar() @safe { return (); // <-- Error } } void main() { auto s = S(); s.bar();

Re: isNumeric bugfix or 2.072 regression?

2017-02-16 Thread Johan Engelen via Digitalmars-d-learn
On Thursday, 16 February 2017 at 23:15:09 UTC, Johan Engelen wrote: Hi all, `isNumeric!string` no longer works like it did in 2.071 when both std.string and std.traits are imported. https://issues.dlang.org/show_bug.cgi?id=17190

isNumeric bugfix or 2.072 regression?

2017-02-16 Thread Johan Engelen via Digitalmars-d-learn
Hi all, `isNumeric!string` no longer works like it did in 2.071 when both std.string and std.traits are imported. This code no longer compiles with 2.072: ```d // RUN: dmd -c test.d import std.string; import std.traits; void foo() { static if (isNumeric!string) {} } ``` The error is

Re: Force inline

2017-02-20 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 20 February 2017 at 13:16:15 UTC, Jonathan M Davis wrote: dmd is great for fast compilation and therefore it's great for development. However, while it produces decent binaries, and it may very well do certain optimizations better than the gcc or llvm backends do This I find hard

Re: Different array rotation algorithms benchmark

2016-09-01 Thread Johan Engelen via Digitalmars-d-learn
On Thursday, 1 September 2016 at 10:37:18 UTC, Miguel L wrote: Also, forgot to specify I am using LDC with -05. And the version of LDC too please ;-)

Re: Binary heap: obtain a _reference_ to the front of the heap

2016-09-14 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 13 September 2016 at 08:55:15 UTC, Nicholas Wilson wrote: On Tuesday, 13 September 2016 at 08:19:04 UTC, Johan Engelen wrote: In the binary heap documentation, I read that `BinaryHeap.front()` "Returns a copy of the front of the heap". [1] Is there no function to access the front

Binary heap: obtain a _reference_ to the front of the heap

2016-09-13 Thread Johan Engelen via Digitalmars-d-learn
In the binary heap documentation, I read that `BinaryHeap.front()` "Returns a copy of the front of the heap". [1] Is there no function to access the front of the heap without a copy? (micro-optimization) Thanks, Johan [1]

Re: Template overloads involving `string` and `char[constant]` return value

2016-09-21 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 12:20:14 UTC, Adam D. Ruppe wrote: It is neither, the compiler chose the right overload (remember, overloads are chosen based on the arguments alone, the type you specify for the variable holding the return value isn't a consideration there) and the

Re: Template overloads involving `string` and `char[constant]` return value

2016-09-21 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 13:06:08 UTC, Adam D. Ruppe wrote: the variable you are assigning the result to never does anything with regard to overloads or template args. Gotcha, thanks.

Re: Template overloads involving `string` and `char[constant]` return value

2016-09-21 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 12:20:14 UTC, Adam D. Ruppe wrote: This is a pretty common pitfall (and IMO one of the most egregious design flaws in the language), I see it all the time. I write very little D code, so I guess it had to happen at some point then. Man, this is really bad

Template overloads involving `string` and `char[constant]` return value

2016-09-21 Thread Johan Engelen via Digitalmars-d-learn
What's the bug in the following code: ```d import std.digest.md; import std.stdio; pragma(inline, false) // just in case string getHash() { ubyte[16] hash = [1,2,3,4,5,6,6,78,8,8,7,7,6,3,2,3]; string a = toHexString(hash); return a; } pragma(inline, false) // just in case void

Re: Binary heap: obtain a _reference_ to the front of the heap

2016-09-15 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 13 September 2016 at 08:19:04 UTC, Johan Engelen wrote: In the binary heap documentation, I read that `BinaryHeap.front()` "Returns a copy of the front of the heap". [1] Is there no function to access the front of the heap without a copy? (micro-optimization) Answering myself

Re: compile error while use `extern(C++, class)`

2016-08-18 Thread Johan Engelen via Digitalmars-d-learn
On Thursday, 18 August 2016 at 11:43:03 UTC, Lodovico Giaretta wrote: On Thursday, 18 August 2016 at 11:11:10 UTC, mogu wrote: Compiler Error exactly. The minimal code is(dmd or ldc2 in ubuntu 16.04 lts): ``` extern (C++, struct) class A {} ``` Error: identifier expected for C++ namespace

Re: using .init reliably

2016-08-26 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 26 August 2016 at 09:48:00 UTC, Jonathan M Davis wrote: You're supposed to be able to depend on .init existing. Default initialization for structs can be disabled via @disable this(); but even then, the init member still exists (it just isn't used for default initialization).

Re: List defined version specifications

2016-10-19 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 19 October 2016 at 10:25:51 UTC, Lodovico Giaretta wrote: Hi! A simple question: is there a way to list all defined version specifications? Perhaps not what you are looking for but on the commandline: bin/ldc2 -v test.d ... predefs LDC all D_Version2 assert X86_64

Re: Visual Studio Linker Problem

2016-10-18 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 18 October 2016 at 05:23:15 UTC, Jason C. Wells wrote: I am working my way up to building NanoVG per my previous post. I am able to compile hello world using dmd2. I am running in cygwin because I understand bash way better than cmd.exe. Does `ldc2 hello.d` also fail in cmd.exe?

Re: Visual Studio Linker Problem

2016-10-18 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 18 October 2016 at 17:29:34 UTC, Jason C. Wells wrote: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat did in fact exist. My search for the file must have been errant. ldc2.exe hello.d also failed in cmd.exe. I took Mike's advice to run cmd.exe from one of

Re: exercise - find invalid D tokens (Impossible ?)

2016-10-28 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 28 October 2016 at 05:16:45 UTC, Basile B. wrote: Here are the specifications of token strings: "Token strings open with the characters q{ and close with the token }. In between must be valid D tokens. The { and }" So we can deduce that any invalid D token inside a token string

Re: Building DMD with DMD or LDC

2016-10-16 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 15 October 2016 at 07:39:31 UTC, ketmar wrote: On Friday, 14 October 2016 at 15:13:58 UTC, Jonathan M Davis wrote: On Thursday, October 13, 2016 19:07:44 Nordlöw via Digitalmars-d-learn wrote: Is there a large speed difference in compilation time depending on whether the DMD used

Re: Dynamic arrays with static initialization and maybe a bug with sizeof

2016-12-13 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 13 December 2016 at 21:27:57 UTC, Xavier Bigand wrote: Hi, I have the following code snippet : voidset() { GLfloat[] data = [ -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f,

Re: Question about compile-time functions.

2016-12-14 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 14 December 2016 at 07:15:08 UTC, Bauss wrote: If a function is only called during compile-time will it be available at runtime? With "available at runtime", I guess you mean "will it be part of the object file". In that case: yes. Because even if a function is _never_ called,

Re: Where should I dump workarounds?

2016-11-30 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 30 November 2016 at 18:50:42 UTC, Dukc wrote: On Wednesday, 30 November 2016 at 18:26:32 UTC, Jonathan M Davis wrote: [snip] - Jonathan M Davis Luckily, I have made a branch for my stuff instead of using master. But thanks for the help, now I know that it does not matter

Re: CTFE difference between dmd and ldc2

2016-12-27 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 27 December 2016 at 17:56:07 UTC, Stefan Koch wrote: On Tuesday, 27 December 2016 at 17:50:15 UTC, Joseph Rushton Wakeling wrote: Hello all, [ ... ] Can anyone advise what could be going wrong here? This looks like a nasty CTFE bug to me :-( Thanks & best wishes, -- Joe I

Re: Building a project with CMAKE

2017-03-04 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 3 March 2017 at 22:06:11 UTC, berni wrote: On Friday, 3 March 2017 at 20:10:25 UTC, Ali Çehreli wrote: Which would put gdc in between the two. Is your experience different? Actually, I've got not much experience. A few weeks ago I ran a test where ldc was in between dmd and gdc.

Re: Building a project with CMAKE

2017-03-05 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 4 March 2017 at 18:45:22 UTC, berni wrote: [...] If you think, this program could be usefull for you, I can email it to you... The smaller the testcase, the better. You mentioned that for testcase "B" there is a ~10% performance difference between GDC and LDC, so that's

Re: Alignment of struct containing SIMD field - GDC

2017-03-02 Thread Johan Engelen via Digitalmars-d-learn
On Thursday, 2 March 2017 at 13:00:08 UTC, Cecil Ward wrote: Raised bug here, and I'm raising a PR now also. https://issues.dlang.org/show_bug.cgi?id=17237 Iain, this of course is present in my version of LDC too. (I checked.) You couldn't poke David Nadlinger or whoever for me? Poke

Re: Alignment of struct containing SIMD field - GDC

2017-03-01 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 1 March 2017 at 18:34:16 UTC, Iain Buclaw wrote: Simple test case would be: struct vec_struct { bool b2; struct { bool b; int8 field; } } static assert(vec_struct.b.offsetof == 32); static assert(vec_struct.field.offsetof == 64); With explicit

Re: Is DMD breaking BigInt?

2017-04-08 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 8 April 2017 at 12:16:10 UTC, Russel Winder wrote: Fedora Rawhide is now on LLVM 4.0 is that going to be a problem building LDC? Of course not! ;-) -Johan

Re: Question on SSE intrinsics

2017-07-29 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 29 July 2017 at 16:01:07 UTC, piotrekg2 wrote: Hi, I'm trying to port some of my c++ code which uses sse2 instructions into D. The code calls the following intrinsics: - _mm256_loadu_si256 - _mm256_movemask_epi8 Do they have any equivalent intrinsics in D? Yes, with LDC

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 13 August 2017 at 09:08:14 UTC, Petar Kirov [ZombineDev] wrote: This instantiation: sum_subranges(std.range.iota!(int, int).iota(int, int).Result, uint) of the following function: auto sum_subranges(T)(T input, uint range) { import std.range : chunks, ElementType, array;

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 13 August 2017 at 09:15:48 UTC, amfvcg wrote: Change the parameter for this array size to be taken from stdin and I assume that these optimizations will go away. This is paramount for all of the testing, examining, and comparisons that are discussed in this thread. Full

Re: Is align(16) respected for globals?

2017-07-23 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 23 July 2017 at 08:43:33 UTC, Guillaume Piolat wrote: I rely a lot on such constants for SSE: align(16) static immutable short[8] A = [ 1, 1, 1, 1, 3, 3, 3, 3 ]; Does such alignment actually work on all OS, at all times? Word on the street says align() doesn't work with

Re: Create class on stack

2017-08-08 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 7 August 2017 at 13:40:18 UTC, Moritz Maxeiner wrote: Thanks, I wasn't aware of this. I tried fooling around scope classes and DIP1000 for a bit and was surprised that this is allowed: Thanks for the test case :-) It was fun to see that ASan can catch this bug too. Because

Express "Class argument may not be null" ?

2017-08-08 Thread Johan Engelen via Digitalmars-d-learn
Hi all, How would you express the function interface intent that a reference to a class may not be null? For a function "void foo(Klass)", calling "foo(null)" is valid. How do I express that that is invalid? (let's leave erroring with a compile error aside for now) Something equivalent to

Re: Express "Class argument may not be null" ?

2017-08-08 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 18:57:48 UTC, Steven Schveighoffer wrote: On 8/8/17 2:34 PM, Johan Engelen wrote: Hi all, How would you express the function interface intent that a reference to a class may not be null? For a function "void foo(Klass)", calling "foo(null)" is valid. How do I

Re: Express "Class argument may not be null" ?

2017-08-08 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 19:38:19 UTC, Steven Schveighoffer wrote: Note that C++ also can do this, so I'm not sure the & is accomplishing the correct goal: void foo(Klass&); int main() { Klass *k = NULL; foo(*k); } In C++, it is clear that the _caller_ is doing the

Re: How to fix wrong deprecation message - dmd-2.075.1

2017-08-16 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 16 August 2017 at 16:54:04 UTC, Pham wrote: On Wednesday, 16 August 2017 at 13:55:31 UTC, Steven Schveighoffer wrote: On 8/16/17 9:12 AM, Daniel Kozak via Digitalmars-d-learn wrote: It should not be print? AIAIK std.utf.toUTF16 is not deprecated:

Re: Zero-cost version-dependent function call at -O0.

2017-06-26 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 25 June 2017 at 23:02:28 UTC, Adam D. Ruppe wrote: On Sunday, 25 June 2017 at 22:53:07 UTC, Johan Engelen wrote: I meant semantically no call. In the existing language, I think version (or static if) at the usage and definition points both is as good as you're going to get. At

Re: Zero-cost version-dependent function call at -O0.

2017-06-26 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 25 June 2017 at 23:02:28 UTC, Adam D. Ruppe wrote: That'd be kinda tricky because the arguments would still be liable to be evaluated... Well.. I guess someone might argue that's a mis-feature of my preprocessor example: "foo(i++)" may not do what you want. (So the C code

Zero-cost version-dependent function call at -O0.

2017-06-25 Thread Johan Engelen via Digitalmars-d-learn
How would you solve this problem: do an optional function call depending on some version(X). If version(X) is not defined, there should be no call and no extra code at -O0. ``` { ... foo(); // either compiles to a function call, or to _nothing_. ... } ``` In C, you could do something

Re: Zero-cost version-dependent function call at -O0.

2017-06-25 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 25 June 2017 at 16:31:52 UTC, Moritz Maxeiner wrote: On Sunday, 25 June 2017 at 15:58:48 UTC, Johan Engelen wrote: [...] If version(X) is not defined, there should be no call and no extra code at -O0. [...] In C, you could do something like: ``` #if X void foo() {..} #else

Re: Zero-cost version-dependent function call at -O0.

2017-06-25 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 25 June 2017 at 16:29:20 UTC, Anonymouse wrote: Am I missing something, or can't you just version both the function and the function ćall? version(X) void foo() { /* ... */ } void main() { version(X) { foo(); } } I am hoping for something where "foo()" would

Re: Zero-cost version-dependent function call at -O0.

2017-06-25 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 25 June 2017 at 22:23:44 UTC, Moritz Maxeiner wrote: The solution obviously does *not* work if you change the premise of your question after the fact by artificially injecting instructions into all function bodies I meant semantically no call. I am asking for a little more

Re: how to disable inlining of ldc2 when 'dub build --build=release'?

2017-05-20 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 20 May 2017 at 08:02:26 UTC, lixiaozi wrote: [...] I noticed it's the inline optimization in ldc2 that caused the crash. If you are certain that your code is 100% correct, please file a bug report. Inlining is done by LLVM and it is rare to find an LLVM bug like that (what

Re: how to disable inlining of ldc2 when 'dub build --build=release'?

2017-05-20 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 20 May 2017 at 08:02:26 UTC, lixiaozi wrote: Now, I try to disable inlining in "dub.json" like == "dflags":[ "-disable-inlining" ], == but it doesn't work, because then dub calls ldc2 like this: 'ldc2 -disable-inlining -release -enable-inlining

Re: Is D slow?

2017-06-10 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 10 June 2017 at 11:43:06 UTC, Johan Engelen wrote: On Friday, 9 June 2017 at 16:21:22 UTC, Honey wrote: What seems particularly strange to me is that -boundscheck=off leads to a performance decrease. Strange indeed. `-release` should be synonymous with `-release

Re: Is D slow?

2017-06-10 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 9 June 2017 at 16:21:22 UTC, Honey wrote: What seems particularly strange to me is that -boundscheck=off leads to a performance decrease. Strange indeed. `-release` should be synonymous with `-release -boundscheck=off`. Investigating... - Johan

Re: Solution to "statement is not reachable" depending on template variables?

2017-06-18 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 18 June 2017 at 09:56:50 UTC, Steven Schveighoffer wrote: On Sunday, 18 June 2017 at 09:28:57 UTC, Johan Engelen wrote: Reviving this thread to see whether anything has changed on the topic. If Timon gets static for each into the language, it can look a little better. Can you

Re: Solution to "statement is not reachable" depending on template variables?

2017-06-18 Thread Johan Engelen via Digitalmars-d-learn
Reviving this thread to see whether anything has changed on the topic. I now have this monster: ``` struct FMT { // has immutable members. FMT cannot be assigned to. } FMT monsterThatCompilerAccepts(T)(){ alias TP = Tuple!(__traits(getAttributes, T)); foreach(i, att; TP){

Re: Is there further documentation of core.atomic.MemoryOrder?

2017-09-17 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 13 September 2017 at 14:40:55 UTC, Nathan S. wrote: Is there a formal description of "hoist-load", "hoist-store", "sink-load", and "sink-store" as used in core.atomic.MemoryOrder (https://dlang.org/library/core/atomic/memory_order.html)? You can read this:

Re: Access Violation when passing the result of a C function directly to a D function?

2017-09-17 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 15 September 2017 at 04:01:13 UTC, Timothy Foster wrote: I've been calling it like so: ErrorFMOD(FMOD_System_Create(), "Error Creating System: "); Making the calls without my helper function doesn't cause an Access Violation. Calling it like this is the only thing that seems to

Re: SIMD under LDC

2017-09-07 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 6 September 2017 at 20:43:01 UTC, Igor wrote: I opened a feature request on github. I also tried using the gccbuiltins but I got this error: LLVM ERROR: Cannot select: 0x2199c96fd70: v16i8 = X86ISD::PSHUFB 0x2199c74e9a8, 0x2199c74d6c0 That's because SSSE3 instructions are

Re: One path skips constructor - is this a bug?

2017-09-07 Thread Johan Engelen via Digitalmars-d-learn
On Thursday, 7 September 2017 at 16:08:53 UTC, Piotr Mitana wrote: main.d(17): Error: one path skips constructor main.d(15): Error: return without calling constructor http://www.digitalmars.com/d/archives/digitalmars/D/learn/Throwing_exception_in_constructor_28995.html

Re: performance cost of sample conversion

2017-09-07 Thread Johan Engelen via Digitalmars-d-learn
On Thursday, 7 September 2017 at 05:45:58 UTC, Ali Çehreli wrote: You have to measure. Indeed. Here's a start: The program has way too many things pre-defined, and the semantics are such that workWithDoubles can be completely eliminated... So you are not measuring what you want to be

Re: SIMD under LDC

2017-09-05 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 4 September 2017 at 20:39:11 UTC, Igor wrote: I found that I can't use __simd function from core.simd under LDC and that it has ldc.simd but I couldn't find how to implement equivalent to this with it: ubyte16* masks = ...; foreach (ref c; pixels) { c = __simd(XMM.PSHUFB,

Re: Fast removal of character

2017-10-11 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 11 October 2017 at 22:45:14 UTC, Jonathan M Davis wrote: On Wednesday, October 11, 2017 22:22:43 Johan Engelen via Digitalmars-d- learn wrote: std.string.removechars is now deprecated. https://dlang.org/changelog/2.075.0.html#pattern-deprecate What is now the most efficient way

  1   2   >