Thread overview
How to access to struct via pointer.
Jul 17, 2021
sergey volkovich
Jul 17, 2021
Dennis
July 17, 2021

Hello.
I had next example C code

#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?

July 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 stuff

A literal translation would be:

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.

July 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