Re: How to handle nested structs when converting C headers?

2013-12-12 Thread Regan Heath
On Thu, 12 Dec 2013 00:04:07 -, H. S. Teoh hst...@quickfur.ath.cx wrote: On Thu, Dec 12, 2013 at 12:54:58AM +0100, Gary Willoughby wrote: On Wednesday, 11 December 2013 at 23:38:13 UTC, Adam D. Ruppe wrote: On Wednesday, 11 December 2013 at 23:35:04 UTC, Gary Willoughby wrote: static

Re: How to handle nested structs when converting C headers?

2013-12-12 Thread bearophile
Regan Heath: I would stop nesting the struct definition. I think that is both cleaner and closer to the original intent - the only reason it is nested in C is because C allows definition and declaration that way, and D does not. Then you don't need static at all. It's mostly a matter of

Re: How to handle nested structs when converting C headers?

2013-12-12 Thread Jacob Carlborg
On 2013-12-11 23:45, Gary Willoughby wrote: How to handle nested structs when converting C headers? In the following snippet i'm currently converting, how would you convert the nested typed union and structures? Would you declare them separately then use their types in the Tcl_Obj struct? or is

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Adam D. Ruppe
On Wednesday, 11 December 2013 at 22:45:35 UTC, Gary Willoughby wrote: How to handle nested structs when converting C headers? Nested structs and unions like in your example are supported in D too, same syntax, same effect.

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Adam D. Ruppe
On Wednesday, 11 December 2013 at 22:54:04 UTC, Adam D. Ruppe wrote: Nested structs and unions like in your example are supported in D too, same syntax, same effect. Actually, no, not quite the same syntax, I didn't notice the name at the end of the C one (in D, the anonymous nested structs

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread bearophile
Adam D. Ruppe: Nested structs and unions like in your example are supported in D too, same syntax, same effect. But don't forget to add to use static struct instad of struct. Bye, bearophile

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Gary Willoughby
On Wednesday, 11 December 2013 at 23:12:39 UTC, bearophile wrote: Adam D. Ruppe: Nested structs and unions like in your example are supported in D too, same syntax, same effect. But don't forget to add to use static struct instad of struct. Bye, bearophile Have you got an example

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Gary Willoughby
On Wednesday, 11 December 2013 at 23:27:57 UTC, Gary Willoughby wrote: On Wednesday, 11 December 2013 at 23:12:39 UTC, bearophile wrote: Adam D. Ruppe: Nested structs and unions like in your example are supported in D too, same syntax, same effect. But don't forget to add to use static

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Adam D. Ruppe
On Wednesday, 11 December 2013 at 23:35:04 UTC, Gary Willoughby wrote: static union internalRep try static union InternalRep { /* note the capital letter */ /* snip */ } InternalRep internalRep;; // still need a decl

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread bearophile
Gary Willoughby: Have you got an example because i always get: tcl.d(713): Error: no identifier for declarator twoPtrValue tcl.d(718): Error: no identifier for declarator ptrAndLongRep tcl.d(719): Error: no identifier for declarator internalRep In D you can't define a struct/union and use it

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Adam D. Ruppe
On Wednesday, 11 December 2013 at 23:36:11 UTC, bearophile wrote: In D you can't define a struct/union and use it to define an instance on the fly. Well, you can if it is anonymous. struct Foo { union { struct { ubyte a; ubyte b; } ubyte[2] arr; } } That works in D,

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread bearophile
Adam D. Ruppe: Well, you can if it is anonymous. struct Foo { union { struct { ubyte a; ubyte b; } ubyte[2] arr; } } That works in D, and it makes foo.a == arr[0] and foo.b == arr[1]; Right :-) I like D structs. Bye, bearophile

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Gary Willoughby
On Wednesday, 11 December 2013 at 23:38:13 UTC, Adam D. Ruppe wrote: On Wednesday, 11 December 2013 at 23:35:04 UTC, Gary Willoughby wrote: static union internalRep try static union InternalRep { /* note the capital letter */ /* snip */ } InternalRep internalRep;; // still need a decl

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread H. S. Teoh
On Thu, Dec 12, 2013 at 12:54:58AM +0100, Gary Willoughby wrote: On Wednesday, 11 December 2013 at 23:38:13 UTC, Adam D. Ruppe wrote: On Wednesday, 11 December 2013 at 23:35:04 UTC, Gary Willoughby wrote: static union internalRep try static union InternalRep { /* note the capital