Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
March 19, 2021 Pointers to structures | ||||
---|---|---|---|---|
| ||||
Could it be made acceptable, at least for -betterC option, to use '->' as an alternative to '.'? 'ptrStructVar->MemOfStructVar' is a very common idiom in C. Best regards |
March 19, 2021 Re: Pointers to structures | ||||
---|---|---|---|---|
| ||||
Posted in reply to DLearner | On Friday, 19 March 2021 at 11:23:36 UTC, DLearner wrote:
>
> Could it be made acceptable, at least for -betterC option, to use '->' as an alternative to '.'?
>
> 'ptrStructVar->MemOfStructVar' is a very common idiom in C.
>
> Best regards
You could try search and replace '->' with '.' see how it goes
|
March 19, 2021 Re: Pointers to structures | ||||
---|---|---|---|---|
| ||||
Posted in reply to DLearner | On Friday, 19 March 2021 at 11:23:36 UTC, DLearner wrote:
>
> Could it be made acceptable, at least for -betterC option, to use '->' as an alternative to '.'?
>
> 'ptrStructVar->MemOfStructVar' is a very common idiom in C.
>
> Best regards
In D '.' can be used to access the member of a struct regardless of whether you are manipulating the struct itself or a pointer to that struct. So you can just write 'ptrStructVar.MemOfStructVar' and it will work without any issue.
|
March 19, 2021 Re: Pointers to structures | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cym13 | On Friday, 19 March 2021 at 12:19:47 UTC, Cym13 wrote:
> In D '.' can be used to access the member of a struct regardless of whether you are manipulating the struct itself or a pointer to that struct. So you can just write 'ptrStructVar.MemOfStructVar' and it will work without any issue.
i guess, idea was to reduce manual work then adapt C sources to D.
i have similar wishes for "typedef ...".
it is boring to rewrite it then making C binding.
|
March 19, 2021 Re: Pointers to structures | ||||
---|---|---|---|---|
| ||||
Posted in reply to novice3 | On Friday, 19 March 2021 at 13:15:16 UTC, novice3 wrote: > On Friday, 19 March 2021 at 12:19:47 UTC, Cym13 wrote: >> In D '.' can be used to access the member of a struct regardless of whether you are manipulating the struct itself or a pointer to that struct. So you can just write 'ptrStructVar.MemOfStructVar' and it will work without any issue. > > i guess, idea was to reduce manual work then adapt C sources to D. > i have similar wishes for "typedef ...". > it is boring to rewrite it then making C binding. Nobody needs to manually write bindings nowadays https://github.com/jacob-carlborg/dstep I use it to generate the bindings of the C headers libs i need Works most of the time, sometimes i have to do some cleanup, but it's faster than doing all the thing manually Alternatively one can use dpp https://github.com/atilaneves/dpp |
Copyright © 1999-2021 by the D Language Foundation