如何从对用户隐藏定义的结构中取消引用成员?

How to dereference member from struct in which the definition is hid from user?

Payload_Manager.h

typedef struct ATEIS_Payload_s* pATEIS_Payload;

Payload_Manager.c

#include "Payload_Manager.h"

struct __attribute__((__packed__))ATEIS_Payload_s   //payload
{
    uint32_t Addr;
    uint16_t Cmd;
    uint16_t Len;
    uint8_t Data[]; 
};

DNM_Manager.h

#include "Payload_Manager.h"

typedef struct DNM_s* pDNM;

pDNM DNMManager_Ctor(pDNM this, pATEIS_Payload src);

DNM_Manager.c

#include "Payload_Manager.h"

struct DNM_s
{
    uint32_t Addr;
    uint32_t SerialNo;
    uint32_t SubnetMask;
    uint16_t Tick;
    uint8_t Name[NAME_SIZE];
}DNMSet[SET_SIZE], DNMTemp;

pDNM DNMManager_Ctor(pDNM this, pATEIS_Payload src)
{
    memcpy(this->Name, &src->Data[NAME], NAME_SIZE);    //ptr to incomplete class type is not allowed
    this->Addr = src->Addr;    //ditto
    this->SerialNo = *(uint32_t*)&src->Data[SN];    //ditto
    this->SubnetMask = *(uint32_t*)&src->Data[SUBMASK];    //ditto
    this->Tick = 0;
    return this;
}

main.c

#include "Payload_Manager.h"
#include "DNM_Manager.h"

pDNM DNM_temp = NULL;
DNM_temp = DNMManager_New();    //get one DNM
DNM_temp = DNMManager_Ctor(DNM_temp, pl_p);    //init DNM_temp by pl_p

文件 DNM_Manager.c 需要知道 ATEIS_Payload_s 的声明,否则无法取消引用它。

除了在 DNM_Manager.c 中再次声明 ATEIS_Payload_s 之外,我该怎么办?

谢谢。

正如 Groo 所建议的,实施者必须向用户提供操作成员的功能。这是我的代码片段:

uint32_t PayloadManager_GetAddr(ATEIS_Payload_s* this)
{
    return this->Addr;
}