Re: Meta-programming detecting anonymous unions inside structs.

2016-10-21 Thread TheFlyingFiddle via Digitalmars-d-learn
On Friday, 21 October 2016 at 08:18:58 UTC, rikki cattermole wrote: On 21/10/2016 9:13 PM, TheFlyingFiddle wrote: On Friday, 21 October 2016 at 07:56:27 UTC, rikki cattermole wrote: You're gonna have to use UDA's for that. Yes, to do the serialization you're right. But my usecase for this

Re: Meta-programming detecting anonymous unions inside structs.

2016-10-21 Thread rikki cattermole via Digitalmars-d-learn
On 21/10/2016 9:13 PM, TheFlyingFiddle wrote: On Friday, 21 October 2016 at 07:56:27 UTC, rikki cattermole wrote: You're gonna have to use UDA's for that. Yes, to do the serialization you're right. But my usecase for this is for error reporting. Basically any struct that contains unions

Meta-programming detecting anonymous unions inside structs.

2016-10-21 Thread TheFlyingFiddle via Digitalmars-d-learn
I am trying to port a serialization library I wrote in Lua some time ago. I've ran into a problem relating to types with anonymous unions inside. Given this code: enum Kind { none = 0, array, integer, floating, } struct Foo { Kind type; union { ulong integer;

Re: Meta-programming detecting anonymous unions inside structs.

2016-10-21 Thread rikki cattermole via Digitalmars-d-learn
On 21/10/2016 8:55 PM, TheFlyingFiddle wrote: I am trying to port a serialization library I wrote in Lua some time ago. I've ran into a problem relating to types with anonymous unions inside. Given this code: enum Kind { none = 0, array, integer, floating, } struct Foo { Kind

Re: Unions and Structs

2016-01-19 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2016-01-18 at 21:50 +0100, Jacob Carlborg via Digitalmars-d- learn wrote: > On 2016-01-18 19:11, Russel Winder via Digitalmars-d-learn wrote: > > > It seems DStep is producing somewhat strange D from complicated C > > unions. > > Please report any issues to [1] with a test case. C code,

Unions and Structs

2016-01-18 Thread Russel Winder via Digitalmars-d-learn
So this is an error? union flob { ulong data; struct thingy { uint data; uint bits; } thingy burble; }; because you cannot have a union field with a name that is also the name of a struct field defined within the union.    --

Re: Unions and Structs

2016-01-18 Thread anonymous via Digitalmars-d-learn
On 18.01.2016 18:10, Russel Winder via Digitalmars-d-learn wrote: So this is an error? union flob { ulong data; struct thingy { uint data; uint bits; } thingy burble; }; because you cannot have a union field with a name that is

Re: Unions and Structs

2016-01-18 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2016-01-18 at 18:17 +0100, anonymous via Digitalmars-d-learn wrote: > On 18.01.2016 18:10, Russel Winder via Digitalmars-d-learn wrote: > > So this is an error? > > > > union flob { > > ulong data; > > struct thingy { > > uint data; > > uint bits; > > }

Re: Unions and Structs

2016-01-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-01-18 19:11, Russel Winder via Digitalmars-d-learn wrote: It seems DStep is producing somewhat strange D from complicated C unions. Please report any issues to [1] with a test case. C code, expected D code, actual D code. [1] https://github.com/jacob-carlborg/dstep/issues --