FROM : Andrew Yager
DATE : Thu Nov 07 21:53:01 2002
Hi,
The following code snippet does not appear to function correctly.
#include <stdio.h>
#define cube(x) x*x*x
int main()
{
int x=1;
int y=2;
int z=3;
int* ptr = &z;
printf("%d\n", *ptr);
printf("%d\n", ptr);
printf("%d\n", cube(*ptr++));
printf("%d\n", *ptr);
printf("%d\n", ptr);
}
--
The preprocess code outputted from cpp is:
# 2 "test.c" 2 3
int main()
{
int x=1;
int y=2;
int z=3;
int* ptr = &z;
printf("%d\n", *ptr);
printf("%d\n", ptr);
printf("%d\n", *ptr++**ptr++**ptr++);
printf("%d\n", *ptr);
printf("%d\n", ptr);
}
However when compiled with łApple Computer, Inc. GCC version 1151, based on
gcc version 3.1 20020420 (prerelease),˛ the following is the output:
3
-1073742488
27
-1073742484
-1073742484
You can see on examination that this should not work... At least if it does
work, it shouldnąt work in this way...!!!!
Sorry for the uninformative error report... Someone with more skill at these
should perhaps do it...
Yours,
Andrew
___________________
Andrew Yager
Real World Technology Solutions
Real People, Real SolUtions (tm)
ph: (02) 9945 2567 fax: (02) 9945 2566
mob: 0405 15 2568
http://www.rwts.com.au/
_________________________
DATE : Thu Nov 07 21:53:01 2002
Hi,
The following code snippet does not appear to function correctly.
#include <stdio.h>
#define cube(x) x*x*x
int main()
{
int x=1;
int y=2;
int z=3;
int* ptr = &z;
printf("%d\n", *ptr);
printf("%d\n", ptr);
printf("%d\n", cube(*ptr++));
printf("%d\n", *ptr);
printf("%d\n", ptr);
}
--
The preprocess code outputted from cpp is:
# 2 "test.c" 2 3
int main()
{
int x=1;
int y=2;
int z=3;
int* ptr = &z;
printf("%d\n", *ptr);
printf("%d\n", ptr);
printf("%d\n", *ptr++**ptr++**ptr++);
printf("%d\n", *ptr);
printf("%d\n", ptr);
}
However when compiled with łApple Computer, Inc. GCC version 1151, based on
gcc version 3.1 20020420 (prerelease),˛ the following is the output:
3
-1073742488
27
-1073742484
-1073742484
You can see on examination that this should not work... At least if it does
work, it shouldnąt work in this way...!!!!
Sorry for the uninformative error report... Someone with more skill at these
should perhaps do it...
Yours,
Andrew
___________________
Andrew Yager
Real World Technology Solutions
Real People, Real SolUtions (tm)
ph: (02) 9945 2567 fax: (02) 9945 2566
mob: 0405 15 2568
http://www.rwts.com.au/
_________________________






Cocoa mail archive

