Garst,

Thanks, but I beg to differ.

When I print sizeof(long) on Linux/386 it shows up as 32 bits.  See below.

Linux test code:

main(){
unsigned long *p1=(void*)0x1000LU, *p2=(void*)0x7000LU, *p3=(void*)0xf000LU;
 unsigned long p2p1 = p2-p1;
 unsigned long p3p1 = p3-p1;

printf ("%8.8lx %8.8lx %p %p %p %i \n", p2p1, p3p1, p1, p2, p3, sizeof(p3));
 printf ("sizeof(long) = %i\n", sizeof(long));

}


Here is the output:

00001800 00003800 0x1000 0x7000 0xf000 4
sizeof(long) = 4

Walt


Garst R. Reese wrote:

Size of long on the intel 386 is 64bits.
On the msp430, it is 32bits. Try long long
Garst

walt spicker wrote:
Hello,

I'm having trouble with the following pointer math.  I get a different
result from the MSP430  GCC when I execute the same code compiled with
GCC for intel 386.  Here is an example:

 unsigned long *p1=(void*)0x1000, *p2=(void*)0x7000, *p3=(void*)0xf000;
 unsigned long p2p1 = p2-p1;
 unsigned long p3p1 = p3-p1;
 static char buf[30];
 snprintf (buf, sizeof(buf), "%8.8lx %8.8lx", p2p1, p3p1);
 PrintLine (buf);

The "PrintLine" function squirts the string out my serial port that I
feed to my terminal emulator for display.  The resulting string is given
below.

00001800 fffff800


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users


Reply via email to