![]() |
![]() |
#1 |
Nov 2003
746010 Posts |
![]()
It's heavy mystery time. Under Linux gcc I have:
#define T 15 #define K 32 printf("%d %d %d %d\n", T, K, T*K, (T)*(K) ); yields 15 32 108 480 !!!!!!! What is the preprocessor doing??? Why is it misinterpreting T*K? and furthermore..... how is it misinterpreting it?????? |
![]() |
![]() |
![]() |
#2 |
May 2008
3·5·73 Posts |
![]()
I get: 15 32 480 480
Which version of GCC? gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC) edit: also tried gcc version 3.4.6 20060404 (Red Hat 3.4.6-9) and it still works. Last fiddled with by jrk on 2009-05-14 at 19:47 |
![]() |
![]() |
![]() |
#3 |
Jan 2008
France
3×181 Posts |
![]()
If you think your preprocessor is playing tricks on you, you can try gcc -E, which will produce a file after preprocessing has been done.
|
![]() |
![]() |
![]() |
#4 |
Jan 2005
Transdniestr
1111101112 Posts |
![]()
Why not use const int rather than define?
|
![]() |
![]() |
![]() |
#5 |
Aug 2006
2×29×103 Posts |
![]() |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
AVX2 weirdness | bsquared | Programming | 1 | 2016-01-17 17:26 |
Achievement? No, just weirdness | R.D. Silverman | Lounge | 5 | 2015-05-14 22:27 |
Linux weirdness; Help? | R.D. Silverman | Programming | 3 | 2009-04-29 12:35 |
Benchmark Weirdness | R.D. Silverman | Hardware | 2 | 2007-07-25 12:16 |
Official Windows Whines and Weirdness Thread | rbarreira | Lounge | 11 | 2005-09-01 06:04 |