我在 64 位 x_86 64 位 OSX 系统中工作。
我正在阅读旧数据库的文件。它被加载到内存块并使用它读取到结构的偏移量。它以 32 位模式编写。
因此,为了在 64 位模式下正确读取,我想在结构的基地址中添加 n 个字节。
由于指针水泥
增量对我没有帮助因为它在 64 位模式下,每个指针都是 b 字节长。
问候,达纳。
我在这里发布了一些代码。估计是对的。。
struct CamNodeTag {
CamNodeTag *nextCam; // next cam
SInt32 numMake;
char *menuMake;
};
long pBaseAddr; // this is long so we an offset bytes from it.
//Get the size of of the structure in 32 bit environment.//in 64 bit envi it is 20 bytes.
int CamNodeTagSizeIn32BitMode = 12;
//Do it in a while loop..
int i=0;
CamNodeTag * pNode = (CamNodeTag *)(pBaseAddr + i*CamNodeTagSizeIn32BitMode);
while(pNode !=NULL)
{
//Do the cam stuff here..
// to get the next node, we add the base addr to the offset
//This will give next cam
i++;
pNode = (CamNodeTag *)(pBaseAddr + i*CamNodeTagSizeIn32BitMode);
}