我們有下面的代碼行:讀一個變量混淆了它?
printf("%d\n", toc->runlist.next);
printf("%d\n", toc->runlist.next);
這些定義:
typedef struct thread_overview_control{
int id[NR_UTHREADS];
list_t runlist;
int active_counter;
int main_thread;
int need_resched;
} thread_overview_control;
thread_overview_control* toc;
我想要做的就是實現用戶線程。出於某種原因,上述代碼在我們的測試運行崩潰時的輸出是:
12345678 //some address
0 //NOW IT'S NULL?!?!?!
這是怎麼發生的?我們所做的只是讀取一個變量。 奇怪的是,沒有printf的,沒有崩潰。這是怎麼回事?
你的意思是,如果你只需要調用 toc-> runlist.next toc-> runlist.next 沒有崩潰? 怎麼樣: INT someint someint = toc-> runlist.next someint = toc-> runlist.next 這是否也產生崩潰? – 2010-05-21 12:20:43