There are two basic misconceptions in your code, Aurel.
Firstly,
sys is not necessarily a pointer. In fact, Oxygen's
sys,
long and
int are currently three different aliases to (i.e. names of) one and the same data type, a 32-bit integer. In 32-bit C, this data type also has three aliases -
long,
long int, or simply
int. 32-bit addresses are expressed as integers so here you may use any alias you like.
Charles is promoting
sys because he plans to extend Oxygen to 64 bits where the meaning of
long and
int may differ. Oxygen's
sys will remain bitness-independent so if you get accustomed to using
sys in your own code then this code will stay valid in both x86 and x64 environments without any modification.
Secondly,
res = *(p+4)................print "value at (p+4):" + *res ' work!is not a solution. It "work!" but only in your hack based on the Oxygen parser's failure to intercept a syntax error at
*(p+4) which yields such an unexpected result. As I said, if
*p works then
*(p+4) should return the value stored 4 bytes away from the address
p.
In more advanced languages, the compiler also keeps track of how long the data that the pointer refers to is. So if the pointer refers to a mere integer like in our case, then it will regard
*(p+1) as "
p plus 4 bytes" because the pointer
p points to
a[...] which is a 32-bit (4-byte) integer. This is called
pointer arithmetics.
And finally, your hack doesn't really need so much effort. It is equivalent to just
p +=4
print "value at (p+4):" + *p ' workS!Thanks for trying anyway, Aurel, and hope my response helps you sort out what is what.