本帖最后由 Jae_1010 于 2022-7-1 13:20 编辑
TDF_MARKET_DATA结构体包含TDF_CODE_INFO结构体指针
[C++] 纯文本查看 复制代码 struct TDF_MARKET_DATA
{...
TDF_CODE_INFO *pCodeInfo;
};
struct TDF_CODE_INFO {...};
使用完TDF_MARKET_DATA结构体数组要一起释放内存
[C++] 纯文本查看 复制代码 void *buffer = (void *)malloc((sizeof(TDF_MARKET_DATA) + sizeof(TDF_CODE_INFO)) * 100);
memset(buffer, 0, (sizeof(TDF_MARKET_DATA) + sizeof(TDF_CODE_INFO)) * 100);
int i = 0;
TDF_MARKET_DATA* tmp = (TDF_MARKET_DATA*)buffer;
TDF_CODE_INFO* tmp2 = (TDF_CODE_INFO*)(tmp + sizeof(TDF_MARKET_DATA) * 100);
此处一个循环
[Asm] 纯文本查看 复制代码 tmp[i].pCodeInfo = &tmp2[i];
tmp[i].pCodeInfo->nMarketID = lpNsqSdkVal->snapshot_code_info_cache[market].nMarketID;
上边这里,ide提示表达式必须是可修改的左值
编译也报错: error: assignment of member ‘TDF_CODE_INFO::nMarketID’ in read-only object
求助大佬,为什么这里是只读,我该怎么写呢 |