Problems with Extern Array of Pointers

Find a Bug? Have a Problem? Like to Suggest a Feature? Do it Here

Moderators: g3nuin3, SpeedWing, WhiteHat, mezzo

Problems with Extern Array of Pointers

Postby daenerys » Tue Sep 07, 2010 12:59 am

Hello,
it seems that there are some problems with array of pointers with external memory variables. There are no problems with the same array of pointers with internal memory/variables. The following snippet gives an example:
Code: Select all
struct PointerArray {
BYTE* ptrByte [4];
}
PointerArray InternMem;
extern PointerArray ExternMem = { "", 0x400000 };
BYTE Octet=123;
InternMem.ptrByte[1]=&Octet;
PrintF ("Intern: %d (equals to 123)", *InternMem.ptrByte [1]);
Octet=*ExternMem.ptrByte[1]; //should read byte at [0x00400004], but gives error "Code emition failed!"
PrintF ("Extern: %d", Octet);


Cheers,
danny
daenerys
Hackleberry Fin
 
Posts: 25
Joined: Wed Jul 26, 2006 6:21 pm

Re: Problems with Extern Array of Pointers

Postby L. Spiro » Tue Sep 07, 2010 5:06 am

You will have to perform the dereferences locally. That means copy the array to a local and initialize a new extern pointer with the address of the dereferenced array index-of-choice.


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan


Return to Bugs/Problems/Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests