- 最後登錄
- 2024-5-7
- 在線時間
- 28995 小時
- 註冊時間
- 2011-12-11
- 閱讀權限
- 95
- 精華
- 3
- UID
- 10643381
- 帖子
- 3222
- 積分
- 24364 點
- 潛水值
- 77260 米
| 如果瀏覽伊莉時速度太慢或無法連接,可以使用其他分流瀏覽伊莉,www01.eyny.com(02,03)。 I'm not sure whether the C or C++ compiler will do the same optimization.
As in C++, if you have a code such as- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- const int i = 100;
- int *p = (int*)(&i);
- *p = 200;
- print f("%d\n", i); // delete the space in print f
- return 0;
- }
複製代碼 you may get the wrong answer 100 , given by the register.
Since some compiler considered it a constant value , the value 100 was loaded
to the register , and give the value from it.
If you declare as "volatile int i" , however , will give the correct answer ,
as it tells the compiler not to do the optimization with the variable i.
(If there is any wrong in the above , please show that. Thanks.)... |
|