How to use the result of __traits( allMembers , T ) with string mixins ?

2014-04-28 Thread ParticlePeter via Digitalmars-d-learn
DMD tells me Error: variable m cannot be read at compile time, but why ? [code] struct MyStruct { float float_value = 0.0f ; ubyte ubyte_value = 2 ; } enum members = [ __traits( allMembers , MyStruct ) ] ; foreach( m ; members ) { mixin( writeln( ~ m ~ , \ : \ , (

Re: How to use the result of __traits( allMembers , T ) with string mixins ?

2014-04-28 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 28 April 2014 at 13:57:56 UTC, Andrej Mitrovic wrote: On Monday, 28 April 2014 at 13:52:52 UTC, ParticlePeter wrote: DMD tells me Error: variable m cannot be read at compile time, but why ? Because 'static foreach' is not an explicit feature yet, so it depends on the context. When

Slow compilation using a lib with template methods

2014-07-05 Thread ParticlePeter via Digitalmars-d-learn
Hello community, here is a post with multiple questions regarding compile times, or rather the optimization of the compile and link process. I work with VisualD and am interested in optimizing my projects with this utility, hence there will be a similar topic linking here, where I explain my

Visual D: Settings to Improve compil and link process

2014-07-05 Thread ParticlePeter via Digitalmars-d-learn
Hello Community, I thought there's a separate forum for VisualD. It did exist when VisualD was on DSource, so why not add it here as well? Or am I to blind to see? Anyway, this thread is an addition to my previous one in this forum:

Re: Visual D: Settings to Improve compil and link process

2014-07-06 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 6 July 2014 at 08:09:07 UTC, Rainer Schuetze wrote: On 05.07.2014 16:05, ParticlePeter wrote: ... It is possible to remove the template methods from my classes, create free functions instead and use them in a UFCS way. Unfortunately I have not figured out UFCS properly, as my

Re: Visual D: Settings to Improve compil and link process

2014-07-07 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 6 July 2014 at 19:27:38 UTC, Rainer Schuetze wrote: Ok, that allows separate compilation of the class, but templates are still compiled with the rest of the program. I thought the templates were the part that cause the slow compilation. I had no chance to profile till now, but I

How to translate this to D: const char *const* someConstPtr;

2015-05-09 Thread ParticlePeter via Digitalmars-d-learn
Hi, const char *const* someConstPtr; Error: no identifier for declarator char* Error: declaration expected, not '*' How would I translate this properly to d? Cheers, PP

Re: Convert C array pointer to a D slice without data copy

2015-05-18 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 18 May 2015 at 09:23:26 UTC, tcak wrote: On Monday, 18 May 2015 at 09:18:33 UTC, ParticlePeter wrote: I get the point to an array from a c function, the data size from another function. The data should be only readable at the D side, but I would like to use it as a D slice without

Convert C array pointer to a D slice without data copy

2015-05-18 Thread ParticlePeter via Digitalmars-d-learn
I get the point to an array from a c function, the data size from another function. The data should be only readable at the D side, but I would like to use it as a D slice without copying the data. Is this possible ?

[DerelictOrg] Forum down ?

2015-04-07 Thread ParticlePeter via Digitalmars-d-learn
Hi, I think I have a bug report for DerelictGL3, but cannot find the related Forum ( http://dblog.aldacron.net/forum/index.php ), is it still in the process of being moved ? Regards, ParticlePeter

Re: [DerelictOrg] Forum down ?

2015-04-07 Thread ParticlePeter via Digitalmars-d-learn
Done On Tuesday, 7 April 2015 at 10:50:35 UTC, Namespace wrote: On Tuesday, 7 April 2015 at 10:48:38 UTC, ParticlePeter wrote: Hi, I think I have a bug report for DerelictGL3, but cannot find the related Forum ( http://dblog.aldacron.net/forum/index.php ), is it still in the process of being

Re: [dimgui] building results in 16 warnings, no error BUT: Building .dub\lib\imgui_d.lib failed!

2015-04-05 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 4 April 2015 at 21:29:57 UTC, Jacques Müller wrote: On Saturday, 4 April 2015 at 18:11:32 UTC, ParticlePeter wrote: Hi, am still searching for the right place to ask library related questions, and was advised to ask them here. The dimgui library looks interesting for my projects

[dimgui] building results in 16 warnings, no error BUT: Building .dub\lib\imgui_d.lib failed!

2015-04-04 Thread ParticlePeter via Digitalmars-d-learn
Hi, am still searching for the right place to ask library related questions, and was advised to ask them here. The dimgui library looks interesting for my projects ( https://github.com/d-gamedev-team/dimgui ), but I don't manage to get it built or run the examples. I have no clue what's going

Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread ParticlePeter via Digitalmars-d-learn
I use wrapper functions taking void[] arrays to forward them comfortably to mentioned OpenGL functions. This works with static and dynamic build in arrays, but I don't see a way how I could access (cast) the raw data of a std.container.array to forward it to these wrapper functions.

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 13:07:11 UTC, Alex Parrill wrote: On Wednesday, 17 June 2015 at 13:04:28 UTC, ParticlePeter wrote: I use wrapper functions taking void[] arrays to forward them comfortably to mentioned OpenGL functions. This works with static and dynamic build in arrays, but I

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 13:31:21 UTC, Marc Schütz wrote: On Wednesday, 17 June 2015 at 13:04:28 UTC, ParticlePeter wrote: I use wrapper functions taking void[] arrays to forward them comfortably to mentioned OpenGL functions. This works with static and dynamic build in arrays, but I

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 13:58:09 UTC, Kagamin wrote: (arr.front())[0 .. arr.length] ? Yes, this works, nice, thanks :-)

Re: Confusion about dynamically and lexically scoped closures

2015-11-08 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 8 November 2015 at 23:17:06 UTC, Jakob Ovrum wrote: The closures for delegates in D1 are never automatically copied to the heap, while in D2 this is done when it's determined that the delegate might outlive one of its upvalues. So, I think it's safe to say we have lexical closures

Confusion about dynamically and lexically scoped closures

2015-11-08 Thread ParticlePeter via Digitalmars-d-learn
Hi, the confusion starts here: http://dlang.org/function.html#closures End of paragraph bellow the last delegate example: "This combining of the environment and the function is called a dynamic closure." While according to https://en.wikipedia.org/wiki/Scope_%28computer_science%29 "Lexical

How to partially forward properties of struct array member to struct (disable length property) ?

2015-09-06 Thread ParticlePeter via Digitalmars-d-learn
I am working on a struct vector. The data is stored in a member static array and I want to be able to forward all array properties except length to vector. Reason is I have free functions f that take vector(s) as arguments, such that f(vector) and vector.f via UFCS is possible. Using alias

Re: How to partially forward properties of struct array member to struct (disable length property) ?

2015-09-06 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 6 September 2015 at 08:48:32 UTC, bioinfornatics wrote: On Sunday, 6 September 2015 at 07:34:36 UTC, ParticlePeter wrote: I am working on a struct vector. The data is stored in a member static array and I want to be able to forward all array properties except length to vector.

Re: Anyone using glad?

2016-01-12 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 11 January 2016 at 00:46:38 UTC, Jason Jeffory wrote: ... OK, I'll give it a try. What about GLUT and WGL? Whats the difference between them all and glfw? Are all these just OS helpers to reduce the boilerplate code? These kind of questions are best clarified on the OpenGL wiki.

How to declare an alias to a function literal type

2016-01-12 Thread ParticlePeter via Digitalmars-d-learn
I have a function type and variable and assign a function to it: void function( int i ) myFunc; myFunc = void function( int i ) { myCode; } How would I declare an alias for void function( int i ) such that the case above would work like this: // alias MF = void function( int i ); // not

Re: How to declare an alias to a function literal type

2016-01-12 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 12 January 2016 at 16:22:48 UTC, ParticlePeter wrote: Actually, I do use only one param, and not int as well, hence I would like the parameter list to be part of the alias. Your example works though. This was confusing, lets start fresh: I have a function "otherFunc" which takes

Re: How to declare an alias to a function literal type

2016-01-12 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 12 January 2016 at 16:00:37 UTC, Daniel Kozak wrote: V Tue, 12 Jan 2016 15:41:02 + ParticlePeter via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> napsáno: I have a function type and variable and assign a function to it: void function( int i ) myFunc; myFunc

Re: How to declare an alias to a function literal type

2016-01-12 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 12 January 2016 at 15:57:03 UTC, Marc Schütz wrote: On Tuesday, 12 January 2016 at 15:41:02 UTC, ParticlePeter wrote: I have a function type and variable and assign a function to it: void function( int i ) myFunc; myFunc = void function( int i ) { myCode; } How would I declare an

Re: How to declare an alias to a function literal type

2016-01-12 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 12 January 2016 at 17:03:49 UTC, Ali Çehreli wrote: On 01/12/2016 08:55 AM, ParticlePeter wrote: > I have a function "otherFunc" which takes a function with lots of > parameters as argument: > > void otherFunc( void function( ref int p1, float p2, ubyte p3, ... ) mf ); Ok. >

Re: How to declare an alias to a function literal type

2016-01-12 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 12 January 2016 at 17:28:35 UTC, Marc Schütz wrote: On Tuesday, 12 January 2016 at 16:55:48 UTC, ParticlePeter wrote: [...] If I understand you correctly (not sure), you would like to write `MF` so that you don't need to specify the parameters in the lambda? That's not possible,

Re: Enum that can be 0 or null

2016-06-06 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 6 June 2016 at 20:32:23 UTC, Alex Parrill wrote: They'd be the same type, since you would define the vulkan functions to take these structures instead of pointer or integer types. It relies on a lot of assumptions about the ABI that make a raw pointer work the same as a structure

Emulate C's (polymorphic) NULL type

2016-06-06 Thread ParticlePeter via Digitalmars-d-learn
In C NULL can be used as integer as well as null pointer. Is there a way to create such a type in D? The type should have only one value which is obviously (0/null). A extern( C ) function should be able to take it as either one. Overloaded enum pops into my mind as example: enum NULL = 0; enum

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 6 June 2016 at 11:40:11 UTC, Anonymouse wrote: On Monday, 6 June 2016 at 09:43:23 UTC, ParticlePeter wrote: In C NULL can be used as integer as well as null pointer. Is there a way to create such a type in D? The type should have only one value which is obviously (0/null). A

Re: Enum that can be 0 or null

2016-06-06 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 21 May 2016 at 06:36:53 UTC, tsbockman wrote: ... As an example, if VK_NULL_HANDLE only ever needs to be assigned to opaque types on the D side (that is, types that serve only as an ID or address for communicating with the C side), you could do this: private struct VkNullHandle

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 6 June 2016 at 16:19:02 UTC, Alex Parrill wrote: On Monday, 6 June 2016 at 09:43:23 UTC, ParticlePeter wrote: In C NULL can be used as integer as well as null pointer. Is there a way to create such a type in D? The type should have only one value which is obviously (0/null). A

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 6 June 2016 at 18:33:36 UTC, ParticlePeter wrote: On Monday, 6 June 2016 at 16:19:02 UTC, Alex Parrill wrote: On Monday, 6 June 2016 at 09:43:23 UTC, ParticlePeter wrote: In C NULL can be used as integer as well as null pointer. Is there a way to create such a type in D? The type

Re: Enum that can be 0 or null

2016-06-07 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 14:31:40 UTC, Alex Parrill wrote: I don't think opCast gets called for implicit conversions; it only gets called for explicit casts. I'll test it later. It does for type bool, but I fear that's the only exception.

Why does std.container.array does not work with foraech( i, a; array ) {} ?

2016-05-29 Thread ParticlePeter via Digitalmars-d-learn
Which of the op(Index) operators is responsible for enabling this kind of syntax? Would it be possible to get it work with UFCS or would I have to wrap the array?

Re: Why does std.container.array does not work with foraech( i, a; array ) {} ?

2016-05-29 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 29 May 2016 at 09:07:07 UTC, Jonathan M Davis wrote: On Sunday, May 29, 2016 07:14:12 ParticlePeter via Digitalmars-d-learn wrote: Which of the op(Index) operators is responsible for enabling this kind of syntax? Would it be possible to get it work with UFCS or would I have

How to return a const handle (view) to a mutable member of an agregate

2016-03-13 Thread ParticlePeter via Digitalmars-d-learn
I have a struct that privately warps an std.container.array. I would like to return a read-only reference of this array, it should not be duplicated. How can I do this? Cheers, ParticlePeter

Re: How to return a const handle (view) to a mutable member of an agregate

2016-03-13 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 13 March 2016 at 20:28:33 UTC, JR wrote: On Sunday, 13 March 2016 at 20:13:03 UTC, Basile B. wrote: On Sunday, 13 March 2016 at 20:10:57 UTC, Basile B. wrote: [...] Basile beat me to it. Yes, ref const(Array!T) accessor. http://dpaste.dzfl.pl/cb2bc5cf9917 Thank you very much,

Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread ParticlePeter via Digitalmars-d-learn
I need to parse an ascii with multiple tokens. The tokens can be seen as keys. After every token there is a bunch of lines belonging to that token, the values. The order of tokens is unknown. I would like to read the file in as a whole string, and split the string with: splitter(fileString,

Re: Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 11:57:49 UTC, ParticlePeter wrote: Stupid typos: I need to parse an ascii file with multiple tokens. ... ... to do this with a lazy result range and without new allocations.

Re: Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-27 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 20:00:55 UTC, wobbles wrote: Again, totally untested, but I think logically it should work. ( No D compiler on this machine so it mightn't even compile :] ) Thanks Wobbles, I took your approach. There were some minor issues, here is a working version: auto

Re: Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 14:20:12 UTC, Andrea Fontana wrote: Any input => output example? Sure, it is ensight gold case file format: FORMAT type: ensight gold GEOMETRY model: 1exgold2.geo** VARIABLE scalar per node: 1 Stress

Re: Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 15:23:38 UTC, Simen Kjaeraas wrote: Without a bit more detail, it's a bit hard to help. std.algorithm.splitter has an overload that takes a function instead of a separator: import std.algorithm; auto a = "a,b;c"; auto b = a.splitter!(e => e == ';'

std.format.formattedRead docs example does not work with a string literal as input, why?

2016-03-31 Thread ParticlePeter via Digitalmars-d-learn
Example from docs: string s = "hello!124:34.5"; string a; int b; double c; formattedRead(s, "%s!%s:%s", , , ); assert(a == "hello" && b == 124 && c == 34.5); now changing the first formattedRead argument to a string literal: formattedRead("hello!124:34.5", "%s!%s:%s", , , ); results in this

Re: std.format.formattedRead docs example does not work with a string literal as input, why?

2016-03-31 Thread ParticlePeter via Digitalmars-d-learn
On Thursday, 31 March 2016 at 18:25:45 UTC, H. S. Teoh wrote: On Thu, Mar 31, 2016 at 06:23:21PM +, ParticlePeter via Digitalmars-d-learn wrote: Example from docs: string s = "hello!124:34.5"; string a; int b; double c; formattedRead(s, "%s!%s:%s", , , ); assert(a ==

Introspect alias name of an aliased type

2016-05-23 Thread ParticlePeter via Digitalmars-d-learn
alias uint32_t = uint; struct Offset() { uint32_t x; uint32_t y; } // Introspect with: void printStructInfo( T )( T info ) { import std.stdio : writefln; foreach (memb; __traits(allMembers, T)) { writefln(typeof(__traits(getMember, info, memb)).stringof); } } // Result is uint

Re: Game Development Using D

2016-05-21 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 21 May 2016 at 16:01:26 UTC, Stefan Koch wrote: On Saturday, 21 May 2016 at 15:53:18 UTC, David wrote: Hi, I want to try to create a game using D. I'm a complete newbie though (other than having C/C++ experience). Where would I start? Does D have an openGL binding? I am assuming

Getting all struct members and values with introspection avoiding string mixins

2016-05-01 Thread ParticlePeter via Digitalmars-d-learn
I am logging arbitrary POD struct types with member names and data: void printStructInfo( T )( T info ) { foreach( i, A; typeof( T.tupleof )) { enum attribName = T.tupleof[i].stringof; writefln( "%s : %s", attribName, mixin( "info." ~ attribName )); } } Is there is some other way

Re: Getting all struct members and values with introspection avoiding string mixins

2016-05-01 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 1 May 2016 at 10:13:47 UTC, H. S. Teoh wrote: On Sun, May 01, 2016 at 09:42:37AM +, ParticlePeter via Digitalmars-d-learn wrote: I am logging arbitrary POD struct types with member names and data: void printStructInfo( T )( T info ) { foreach( i, A; typeof( T.tupleof

Cannot link daimos glfw using x64

2016-05-01 Thread ParticlePeter via Digitalmars-d-learn
I am failing to link statically to glfw library with deimos glfw. The repo includes an example for glfw2. I downloaded the latest glfw2.lib and tried build the example with -m64 and got these errors: C:\ ... \deimos-glfw>dmd GLFW.lib examples/glfw2/openwindow/openwindow.d -m64

Search elemnt in Compile-time Argument List of strings

2016-07-26 Thread ParticlePeter via Digitalmars-d-learn
I want to generate one function for any struct data member, but also want to be able to skip few of the members. The first part works, but I have some trouble with the skipping. I pass the struct type and a Compile-time Argument List of strings as template arguments to a template function,

Re: Search elemnt in Compile-time Argument List of strings

2016-07-26 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 19:30:18 UTC, ParticlePeter wrote: // Second approach, get warnings for every skipped member // and every line after the return statement: // Warning: statement is not reachable void processMember( T, ignore... )() { foreach( member; __traits( allMembers, T )) {

Re: Search elemnt in Compile-time Argument List of strings

2016-07-26 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 21:20:18 UTC, ParticlePeter wrote: ... First of all there seems to be a typo, it should not be: else static if(i + 1 == arg.length) ignore must be used instead of arg, as arg.length is the length of a string: else static if(i + 1 == ignore.length) if ignore is

Re: Search elemnt in Compile-time Argument List of strings

2016-07-26 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 21:01:19 UTC, Ali Çehreli wrote: On 07/26/2016 01:58 PM, ParticlePeter wrote: On Tuesday, 26 July 2016 at 20:18:48 UTC, Steven Schveighoffer wrote: ... void processMember( T, ignore... )() { foreach( member; __traits( allMembers, T )) { // this is a compile-time

Re: Search elemnt in Compile-time Argument List of strings

2016-07-26 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 20:18:48 UTC, Steven Schveighoffer wrote: ... Thanks a lot for this really cool and detailed explanation (upvoting!). It's a bit weird to work on these compile-time things, but they are so cool when you look at what is available in std.meta and std.traits :)

Re: Search elemnt in Compile-time Argument List of strings

2016-07-26 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 20:18:48 UTC, Steven Schveighoffer wrote: ... void processMember( T, ignore... )() { foreach( member; __traits( allMembers, T )) { // this is a compile-time list, so it's a static foreach. foreach(i, arg; ignore ){ // i is the index into the ignore tuple

Re: Transform/Compile to C/CPP as a target

2016-07-24 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 23 July 2016 at 19:20:10 UTC, Jacob Carlborg wrote: On 2016-07-23 14:27, ParticlePeter wrote: Is there any kind of project or workflow that converts D (subset) to C/CPP ? No idea about the status but: https://github.com/adamdruppe/tools/blob/dtoh/dtoh.d Thanks, I am looking

Re: Transform/Compile to C/CPP as a target

2016-07-23 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 23 July 2016 at 12:29:45 UTC, rikki cattermole wrote: On 24/07/2016 12:27 AM, ParticlePeter wrote: Is there any kind of project or workflow that converts D (subset) to C/CPP ? This probably will interest you for ldc:

Transform/Compile to C/CPP as a target

2016-07-23 Thread ParticlePeter via Digitalmars-d-learn
Is there any kind of project or workflow that converts D (subset) to C/CPP ?

How to overload member function pointer and a regualr member function

2017-04-24 Thread ParticlePeter via Digitalmars-d-learn
I would like to have this kind of struct: struct Foo { private int i; void function( int i, float f ) bar; // will be defined at runtime void bar( float f ) { bar( i, f ); } } But apparently the function pointer and the member function cannot have the same name: Error: function

Re: How to overload member function pointer and a regualr member function

2017-04-26 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 26 April 2017 at 08:24:08 UTC, Basile B. wrote: On Tuesday, 25 April 2017 at 18:58:58 UTC, Ali Çehreli wrote: On 04/25/2017 11:54 AM, Ali Çehreli wrote: My analysis is wrong because that writefln() is for the bar(float) overload but I still think what you want is achieved. Ali

Re: How to overload member function pointer and a regualr member function

2017-04-25 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 25 April 2017 at 16:27:43 UTC, Basile B. wrote: On Tuesday, 25 April 2017 at 15:43:48 UTC, ParticlePeter wrote: On Tuesday, 25 April 2017 at 09:50:14 UTC, Basile B. wrote: On Monday, 24 April 2017 at 16:46:21 UTC, ParticlePeter wrote: Thanks for your reply, but that's what I

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-28 Thread ParticlePeter via Digitalmars-d-learn
On Friday, 28 April 2017 at 17:15:54 UTC, kinke wrote: On Friday, 28 April 2017 at 15:56:17 UTC, ParticlePeter wrote: So what next? How can I interface to the cpp function? *** C++: bool cppFunc(float ()[3]) { color[0] = 1; color[1] = 2; color[2] = 3; return true; } *** D:

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-28 Thread ParticlePeter via Digitalmars-d-learn
On Friday, 28 April 2017 at 17:57:34 UTC, Ali Çehreli wrote: On 04/28/2017 08:56 AM, ParticlePeter wrote: > C++ Function: > bool cppFunc( float[3] color ); > > D binding: > extern(C++) bool cppFunc( float[3] color ); > > Using with: > float[3] my_color; > cppFunc( my_color ); > > -> Error:

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-28 Thread ParticlePeter via Digitalmars-d-learn
On Friday, 28 April 2017 at 17:57:34 UTC, Ali Çehreli wrote: On 04/28/2017 08:56 AM, ParticlePeter wrote: > C++ Function: > bool cppFunc( float[3] color ); > > D binding: > extern(C++) bool cppFunc( float[3] color ); > > Using with: > float[3] my_color; > cppFunc( my_color ); > > -> Error:

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-29 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 29 April 2017 at 01:49:56 UTC, Atila Neves wrote: On Friday, 28 April 2017 at 18:41:22 UTC, kinke wrote: On Friday, 28 April 2017 at 18:07:49 UTC, ParticlePeter wrote: Interesting, your example corresponds to my third case, the linker error. I am on Window, building an x64 App,

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-29 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 29 April 2017 at 00:31:32 UTC, Nicholas Wilson wrote: If you are having problems with the linker with Ali's you can do ``` extern(C++) bool cppFunc( float[3] color ); // correct signature, but causes compiler error pragma(mangle, cppFunc.mangleof) float cppFunc(float * color);

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-29 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 29 April 2017 at 10:17:47 UTC, Atila Neves wrote: On Saturday, 29 April 2017 at 06:22:03 UTC, ParticlePeter wrote: On Saturday, 29 April 2017 at 01:49:56 UTC, Atila Neves wrote: On Friday, 28 April 2017 at 18:41:22 UTC, kinke wrote: [...] The worst part about that is mangling

C++ Interfacing:'static' array function parameter contradiction

2017-04-28 Thread ParticlePeter via Digitalmars-d-learn
C++ Function: bool cppFunc( float[3] color ); D binding: extern(C++) bool cppFunc( float[3] color ); Using with: float[3] my_color; cppFunc( my_color ); -> Error: Internal Compiler Error: unable to pass static array to extern(C++) function. Error: Use pointer instead. Using with: cppFunc(

Re: How to overload member function pointer and a regualr member function

2017-04-25 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 25 April 2017 at 09:50:14 UTC, Basile B. wrote: On Monday, 24 April 2017 at 16:46:21 UTC, ParticlePeter wrote: I would like to have this kind of struct: struct Foo { private int i; void function( int i, float f ) bar; // will be defined at runtime void bar( float f ) {

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 22 May 2017 at 13:03:17 UTC, evilrat wrote: On Monday, 22 May 2017 at 11:25:31 UTC, ParticlePeter wrote: Then I am not getting your hack, this function here, does not exist on the C++ side. HACK --- // extern(C++) of course void GetCursorPos(ImVec2* v);

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 22 May 2017 at 14:01:56 UTC, Jerry wrote: IIRC the problem is that it isn't a POD type. ImVec2 has its own default constructor. The problem now is that because it no longer is POD, Window's ABI handles it different and doesn't put the value in a register. Now with D is that you

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 22 May 2017 at 01:27:22 UTC, Nicholas Wilson wrote: On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 22 May 2017 at 07:24:20 UTC, evilrat wrote: On Monday, 22 May 2017 at 06:33:37 UTC, ParticlePeter wrote: On Monday, 22 May 2017 at 01:39:04 UTC, evilrat wrote: And this is actually D problem. In fact first bug report on this thing was dated back to 2014. Still not fixed. Thanks

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 22 May 2017 at 01:39:04 UTC, evilrat wrote: On Monday, 22 May 2017 at 01:27:22 UTC, Nicholas Wilson wrote: Probably because the D side is expecting to have the struct returned in a pointer allocated by the callee and then the C++ puts it in regs and BOOM. If you wrap the C++

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 22 May 2017 at 08:25:45 UTC, evilrat wrote: On Monday, 22 May 2017 at 08:03:07 UTC, ParticlePeter wrote: No, no, this (other) way around :-), still C++ to D. It actually works btw: HACK --- // original C++ ImVec2 GetCursorPos(); // C++ helper void

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-21 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 21 May 2017 at 19:58:32 UTC, Stefan Koch wrote: On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a

C++ binding issues with C++ function returning a simple POD struct.

2017-05-21 Thread ParticlePeter via Digitalmars-d-learn
I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a simple POD struct of two float members. I can use this struct as argument to functions but when it is returned from a

Re: How you guys go about -BetterC Multithreading?

2017-11-27 Thread ParticlePeter via Digitalmars-d-learn
On Friday, 10 November 2017 at 11:55:57 UTC, Guillaume Piolat wrote: For now we do have some @nogc alternatives for mutex, condition variables, thread-pool, file reading, etc... (dplug:core package) for use with the runtime disabled - the middle ground that's way more usable than -betterC.

Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
I upgraded from DMD 2.074.1 (!) to 2.077.1 and tried to compile a mixed c++/d project (DMD links to one c++ lib). Here is the full error message: fatal error C1905: Front end and back end not compatible (must target same processor). LINK : fatal error LNK1257: code generation failed Error:

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 17 December 2017 at 15:57:08 UTC, ParticlePeter wrote: I upgraded from DMD 2.074.1 (!) to 2.077.1 and tried to compile a mixed c++/d project (DMD links to one c++ lib). Here is the full error message: Forgot most important info, ita an x64 project those used VS linker by default

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 17 December 2017 at 16:40:46 UTC, John wrote: Yah the sc.ini file is wrong for Environment64. [Environment64] LIB="%@P%\..\lib64" . . . ; Windows installer uncomments the version detected LINKCMD=%VCINSTALLDIR%\bin\HostX86\x86\link.exe Thanks! Is this a known, reported bug?

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 17 December 2017 at 19:29:00 UTC, ParticlePeter wrote: On Sunday, 17 December 2017 at 19:16:02 UTC, ParticlePeter wrote: On Sunday, 17 December 2017 at 17:56:47 UTC, John wrote: I don't think so, all that would need to be changed is this line:

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 17 December 2017 at 19:16:02 UTC, ParticlePeter wrote: On Sunday, 17 December 2017 at 17:56:47 UTC, John wrote: I don't think so, all that would need to be changed is this line: https://github.com/dlang/dmd/blob/v2.077.1/ini/windows/bin/sc.ini#L53 Not very many people use it I

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 17 December 2017 at 17:56:47 UTC, John wrote: I don't think so, all that would need to be changed is this line: https://github.com/dlang/dmd/blob/v2.077.1/ini/windows/bin/sc.ini#L53 Not very many people use it I guess if it's been there for 8 months lol. Hm, actually that line

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 17 December 2017 at 20:09:02 UTC, ParticlePeter wrote: On Sunday, 17 December 2017 at 19:29:00 UTC, ParticlePeter wrote: On Sunday, 17 December 2017 at 19:16:02 UTC, ParticlePeter [snip] LINKCMD=%VCINSTALLDIR%\bin\HostX32\x64\link.exe or

How you guys go about -BetterC Multithreading?

2017-11-09 Thread ParticlePeter via Digitalmars-d-learn
Any experience reports or general suggestions? I've used only D threads so far.

Re: How you guys go about -BetterC Multithreading?

2017-11-09 Thread ParticlePeter via Digitalmars-d-learn
On Thursday, 9 November 2017 at 12:19:00 UTC, Petar Kirov [ZombineDev] wrote: On Thursday, 9 November 2017 at 11:08:21 UTC, ParticlePeter wrote: Any experience reports or general suggestions? I've used only D threads so far. It would be far easier if you use druntime + @nogc and/or

Re: How you guys go about -BetterC Multithreading?

2017-11-09 Thread ParticlePeter via Digitalmars-d-learn
On Thursday, 9 November 2017 at 12:43:54 UTC, Petar Kirov [ZombineDev] wrote: On Thursday, 9 November 2017 at 12:30:49 UTC, rikki cattermole wrote: On 09/11/2017 12:19 PM, Petar Kirov [ZombineDev] wrote: On Thursday, 9 November 2017 at 11:08:21 UTC, ParticlePeter wrote: Any experience reports

How to instantiate a template struct with a template constructor without relying on auto deduction?

2018-02-21 Thread ParticlePeter via Digitalmars-d-learn
struct Foo(T) { T bar; this(S)(S s) { bar = convert(s); } } auto foo = Foo!int(some_float); this works because S is deduced as typeof(some_float), but how would I instantiate the struct without relying on auto deduction? Suppose we would have this kind of constructor where auto

Re: How to instantiate a template struct with a template constructor without relying on auto deduction?

2018-02-21 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 21 February 2018 at 14:29:31 UTC, Simen Kjærås wrote: On Wednesday, 21 February 2018 at 14:11:10 UTC, ParticlePeter wrote: struct Foo(T) { T bar; this(S)(S s) { bar = convert(s); } } auto foo = Foo!int(some_float); this works because S is deduced as

Re: mixed in struct constructor is ignored when another (non mixed in) constructor is specified

2018-02-26 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 26 February 2018 at 14:42:58 UTC, Adam D. Ruppe wrote: On Monday, 26 February 2018 at 14:38:22 UTC, ParticlePeter wrote: This cool, I didn't know that we can name mixins when instantiating but also never taught that there could be any purpose for naming. Works, thanks. oh yes,

Re: mixed in struct constructor is ignored when another (non mixed in) constructor is specified

2018-02-26 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 26 February 2018 at 14:02:56 UTC, Adam D. Ruppe wrote: On Monday, 26 February 2018 at 12:30:24 UTC, ParticlePeter wrote: Is this expected behavior? yes sort of, but there are bugs associated with it too... I wrote about this in the "Tip of the Week" section here before

mixed in struct constructor is ignored when another (non mixed in) constructor is specified

2018-02-26 Thread ParticlePeter via Digitalmars-d-learn
mixin template Common() { private int m_member; this( int m ) { m_member = m; } } struct Foo { mixin Common; } struct Bar { mixin Common; this( int m, float n ) { m_member = m * n; } } auto foo = Foo(1); // ok auto b_1 = Bar( 1, 2 ); // ok auto b_2 = Bar( 3 ); // Error:

Re: mixed in struct constructor is ignored when another (non mixed in) constructor is specified

2018-02-26 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 26 February 2018 at 12:47:48 UTC, Jonathan M Davis wrote: On Monday, February 26, 2018 12:30:24 ParticlePeter via Digitalmars-d-learn wrote: mixin template Common() { private int m_member; this( int m ) { m_member = m; } } struct Foo { mixin Common; } struct Bar { mixin

Re: How to create DDoc for string mixin generated functions?

2019-11-26 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 26 November 2019 at 13:02:39 UTC, Jonathan M Davis wrote: On Monday, November 25, 2019 9:25:08 AM MST ParticlePeter via ... - Jonathan M Davis Thanks for that thorough explanation. In may case I use the string mixin to forward outer struct property calls to members of an inner

Re: How to create DDoc for string mixin generated functions?

2019-11-27 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 26 November 2019 at 19:41:26 UTC, Adam D. Ruppe wrote: On Tuesday, 26 November 2019 at 19:27:55 UTC, ParticlePeter wrote: In may case I use the string mixin to forward outer struct property calls to members of an inner struct. Did you try opDispatch btw? It might be simpler to

Anything like HPPTOD out there?

2019-11-25 Thread ParticlePeter via Digitalmars-d-learn
I would like to auto convert c++ header to d module. Is there some project aiming for this? I know of VisualD c++ to d conversion wizzard [1] and LLVM tooling based CPP2D [2], both of them aiming for whole cpp conversion. But I a searching for something lightweight like HTOD extended to C++.

How to create DDoc for string mixin generated functions?

2019-11-25 Thread ParticlePeter via Digitalmars-d-learn
I am producing a bunch of functions/methods through string mixins. I also generated DDoc comments for those functions, in the hope that they would produce proper documentation, but they don't. So how can this be accomplished?

  1   2   >