digitalmars.D - How to access to struct via pointer.
- sergey volkovich (21/21) Jul 17 2021 Hello.
- Dennis (9/11) Jul 17 2021 A literal translation would be:
- Steven Schveighoffer (4/5) Jul 17 2021 Wherever in C or C++ you would use `->`, D uses `.`
Hello. I had next example C code ```c #include <thread_definitions.h> struct PROCESS_DATA { .... //thread attributes }; struct PROCESS_ENTRY{ PROCESS_ENTRY* next; //must be betree entry PROCESS_ENTRY* preview; struct PROCESS_DATA process_store; }; PROCESS_ENTRY* current_process = kalloc(sizeof(PROCESS_DATA)); bool create_thread_data(){ .... current_process->next = kalloc(sizeof(PROCESS_DATA)); //how to implement that stuff .... } ``` can you say, how to rewrite them in d?
Jul 17 2021
On Saturday, 17 July 2021 at 11:30:06 UTC, sergey volkovich wrote:current_process->next = kalloc(sizeof(PROCESS_DATA)); //how to implement that stuffA literal translation would be: ```D current_process.next = cast(PROCESS_ENTRY*) kalloc(PROCESS_DATA.sizeof); ``` Though using `PROCESS_DATA.sizeof` for a pointer to a larger structure `PROCESS_ENTRY` looks very sketch, watch that the original C code is correct.
Jul 17 2021
On 7/17/21 7:30 AM, sergey volkovich wrote:can you say, how to rewrite them in d?Wherever in C or C++ you would use `->`, D uses `.` So `a->member` becomes `a.member`. -Steve
Jul 17 2021