Define methods using templates

2014-12-30 Thread Claude via Digitalmars-d-learn
Hello, I'm trying to use templates to define several methods (property setters) within a class to avoid some code duplication. Here is an attempt: class Camera { private: Vector4 m_pos; float m_fov, m_ratio, m_near, m_far; bool m_matrixCalculated; public: void SetProperty(Tin,

Re: Define methods using templates

2014-12-30 Thread Claude via Digitalmars-d-learn
Thanks Steven and Daniel for your explanations. mixin template opAssign(alias Field) { void opAssign(Tin)(auto ref Tin param) @property pure @safe { Field = param; m_matrixCalculated = false; } } mixin opAssign!(m_pos) pos; I

Re: Define methods using templates

2015-01-08 Thread Claude via Digitalmars-d-learn
I just saw this post, which is essentially the same question as Basile Burg's. I hope that a college (in France?) is teaching D and that this is a homework assignment. Cool stuff! :) Maybe using templates to create properties is a bit overkill in this example. But I could not solve what I

Re: Segfault while compiling simple program

2015-12-16 Thread Claude via Digitalmars-d-learn
I tested it on linux (64-bit distro), and it segfaults as well: - $ echo "struct S { ushort a, b; ubyte c, d; } struct T { ushort e; S s; }" > test.d $ dmd -v test.d binarydmd version v2.069.0 config/etc/dmd.conf parse test importall test importobject

Re: Procedural drawing using ndslice

2016-02-12 Thread Claude via Digitalmars-d-learn
Thanks for your replies, John and Ali. I wasn't sure I was clear. I'm going to try to see if I can fit Ali concept (totally lazy, which is what I was looking for) within ndslices, so that I can also use it in 3D and apply window() function to the result and mess around with it.

Procedural drawing using ndslice

2016-02-11 Thread Claude via Digitalmars-d-learn
Hello, I come from the C world and try to do some procedural terrain generation, and I thought ndslice would help me to make things look clean, but I'm very new to those semantics and I need help. Here's my problem: I have a C-style rough implementation of a function drawing a disk into a

Re: LDC with ARM backend

2016-07-21 Thread Claude via Digitalmars-d-learn
On Thursday, 21 July 2016 at 10:30:55 UTC, Andrea Fontana wrote: On Thursday, 21 July 2016 at 09:59:53 UTC, Claude wrote: I can build a "Hello world" program on ARM GNU/Linux, with druntime and phobos. I'll write a doc page about that. It's a good idea :) Done:

Re: LDC with ARM backend

2016-07-21 Thread Claude via Digitalmars-d-learn
On Wednesday, 20 July 2016 at 16:10:48 UTC, Claude wrote: R_ARM_TLS_IE32 used with non-TLS symbol ?? Oh, that was actually quite obvious... If I revert the first android patch on LLVM sources, and build it back it works! I can build a "Hello world" program on ARM GNU/Linux, with druntime

Re: LDC with ARM backend

2016-07-19 Thread Claude via Digitalmars-d-learn
On Friday, 15 July 2016 at 15:24:36 UTC, Kai Nacke wrote: There is a reason why we do not distribute a binary version of LDC with all LLVM targets enabled. LDC still uses the real format of the host. This is different on ARM (80bit on Linux/x86 vs. 64bit on Linux/ARM). Do not expect that

Re: LDC with ARM backend

2016-07-20 Thread Claude via Digitalmars-d-learn
I think my cross-compile LDC is fine. I tried to build this D program: /// loire.d int main() { return 42; } However, the run-time is not (neither is phobos), most of the linker issues come from the druntime. So... I wrote my own druntime. Here's the code: /// dummyruntime.d // from

Re: LDC with ARM backend

2016-07-20 Thread Claude via Digitalmars-d-learn
So I'm trying to build druntime correctly, I corrected some problems here and there, but I still cannot link with libdruntime-ldc.a: /opt/arm-2009q1/bin/arm-none-linux-gnueabi-gcc loire.o lib/libdruntime-ldc.a -o loire I get many errors like:

LDC with ARM backend

2016-07-15 Thread Claude via Digitalmars-d-learn
Hello, I would like to cross-compile a D program from a x86 machine to an ARM target. I work on GNU/Linux Ubuntu 64-bit. I have an ARM gcc toolchain, which I can use to make programs on an ARM Cortex-A9 architecture running a Linux kernel 3.4.11+. I managed to build and install LLVM 3.8.1

Re: LDC with ARM backend

2016-07-15 Thread Claude via Digitalmars-d-learn
On Friday, 15 July 2016 at 15:02:15 UTC, Radu wrote: Hi, LDC on Linux ARM is fairly complete. I think it is a fully supported platform (all tests are passing). Check in https://wiki.dlang.org/Compilers the LDC column. This is the close for a tutorial for cross-compiling

Dynamic arrays, emplace and GC

2016-07-05 Thread Claude via Digitalmars-d-learn
Hello, I've been working on some kind of allocator using a dynamic array as a memory pool. I used emplace to allocate class instances within that array, and I was surprised to see I had to use GC.addRange() to avoid the GC to destroy stuff referenced in that array. Here's a chunk of

Re: Dynamic arrays, emplace and GC

2016-07-05 Thread Claude via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 12:43:14 UTC, ketmar wrote: On Tuesday, 5 July 2016 at 10:04:05 UTC, Claude wrote: So here's my question: Is it normal??? yes. `ubyte` arrays by definition cannot hold pointers, so GC doesn't bother to scan 'em. Ah ok. I tried using void[size] static array and it

Re: LDC with ARM backend

2016-08-09 Thread Claude via Digitalmars-d-learn
On Monday, 1 August 2016 at 06:21:48 UTC, Kai Nacke wrote: Thanks! That's really awesome! Did you manage to build more complex applications? EABI is a bit different from the hardfloat ABI and there may be still bugs lurking in LDC... Unfortunately no, I didn't have the time. I was

Meta-programming: iterating over a container with different types

2016-09-23 Thread Claude via Digitalmars-d-learn
It's more a general meta-programming question than a specific D stuff. For an entity-component engine, I am trying to do some run-time composition: registering a certain type (component) to a structure (entity). I would like to know how I can iterate an entity and get the different type

Re: Conditional Compilation Multiple Versions

2016-10-20 Thread Claude via Digitalmars-d-learn
On Saturday, 13 June 2015 at 12:21:50 UTC, ketmar wrote: On Fri, 12 Jun 2015 20:41:59 -0400, bitwise wrote: Is there a way to compile for multiple conditions? Tried all these: version(One | Two){ } version(One || Two){ } version(One && Two){ } version(One) | version(Two){ } version(One) ||

Re: Meta-programming: iterating over a container with different types

2016-10-20 Thread Claude via Digitalmars-d-learn
On Friday, 23 September 2016 at 12:55:42 UTC, deed wrote: // Maybe you can try using std.variant? Thanks for your answer. However I cannot use variants, as I have to store the components natively in a void[] array (for cache coherency reasons). So I found a way to solve that problem:

Re: Conditional Compilation Multiple Versions

2017-01-09 Thread Claude via Digitalmars-d-learn
Druntime uses this for its translation of POSIX header files: https://github.com/dlang/druntime/blob/master/src/core/sys/posix/config.d An example: https://github.com/dlang/druntime/blob/master/src/core/sys/posix/sys/resource.d#L96 Ok, I see. Thanks! (I've gotta try reggae someday) :)

Re: Conditional Compilation Multiple Versions

2017-01-06 Thread Claude via Digitalmars-d-learn
On Friday, 6 January 2017 at 13:27:06 UTC, Mike Parker wrote: version(Windows) enum bool WindowsSupported = true; else enum bool WindowsSupported = false; Well, yes, that was a bad example. I thought to change it before sending my post but I could find any other meaningful

Re: Conditional Compilation Multiple Versions

2017-01-06 Thread Claude via Digitalmars-d-learn
On Thursday, 20 October 2016 at 09:58:07 UTC, Claude wrote: I'm digging up that thread, as I want to do some multiple conditional compilation a well. Well I'm digging up that thread again, but to post some positive experience feedback this time as I've found an answer to my own questions,

Problem with GC - linking C++ & D (with gdc)

2022-04-26 Thread Claude via Digitalmars-d-learn
Hello, I'm working on a C++ project requiring an XML parser. I decided to make it in D so I could easily parse at run-time or compile-time as I wish. As our project uses a gcc tool-chain, I naturally use GDC (GCC 9.4.0). But I have a few problems with D, linking with it, trying to use

Re: Problem with GC - linking C++ & D (with gdc)

2022-04-26 Thread Claude via Digitalmars-d-learn
On Tuesday, 26 April 2022 at 10:29:39 UTC, Iain Buclaw wrote: On Tuesday, 26 April 2022 at 10:23:15 UTC, Claude wrote: Hello, Hello, <%--SNIP--%> Does anyone have any idea what's going on? (if I just compile a single D file with "int main() { int* a = new int(42); return *a; }", it

Re: Problem with GC - linking C++ & D (with gdc)

2022-04-26 Thread Claude via Digitalmars-d-learn
On Tuesday, 26 April 2022 at 10:23:15 UTC, Claude wrote: It seg-faults... Just to make it clear, it seg-faults at run-time (not at compilation or link time) when I launch the executable "test".

Re: Problem with GC - linking C++ & D (with gdc)

2022-04-26 Thread Claude via Digitalmars-d-learn
On Tuesday, 26 April 2022 at 12:49:21 UTC, Alain De Vos wrote: PS : I use ``` ldc2 --gcc=cc , cc -v : clang version 11.0.1 ``` We only have gcc in our toolchain (we target an ARM-based embedded system). --- I also encountered problems while I was trying to use CTFE only functions (using

CTFE and BetterC compatibility

2022-04-27 Thread Claude via Digitalmars-d-learn
Hello, I want to make a SAX XML parser in D that I could both use at run-time or compile-time. Also when I use it at compile-time, I would like to use BetterC so I don't have to link D-runtime. But I have some compilation problems. I use GDC (GCC 9.4.0). Here's a reduced sample code: ```

Re: CTFE and BetterC compatibility

2022-04-27 Thread Claude via Digitalmars-d-learn
On Wednesday, 27 April 2022 at 14:34:27 UTC, rikki cattermole wrote: This works: Cool, thanks. Unfortunately, with that implementation, I need to know the maximum size for the array. It works for that particular example, but in the context of an XML file analysis, it's a bit awkward.

Re: CTFE and BetterC compatibility

2022-04-27 Thread Claude via Digitalmars-d-learn
On Wednesday, 27 April 2022 at 14:27:43 UTC, Stanislav Blinov wrote: This is a long-standing pain point with BetterC (see https://issues.dlang.org/show_bug.cgi?id=19268). That's what I was afraid of... Thanks for the link to the bug-report. On Wednesday, 27 April 2022 at 14:27:43 UTC,