测试

有一天,你运用了extern、volatile,结构显示conflicting type qualifiers


myhead.h

      1 #ifndef MYHEAD                                                                                              
      2 #define MYHEAD
      3
      4 extern int a;
      5 extern void show();
      6
      7 #endif

test.c

      1 #include <stdio.h>                                                                                          
      2 #include "myhead.h"
      3 int a=3;
      4 int main(int argc, char *argv[])
      5 {
      6
      7     show();
      8     printf("%d\n",3);
      9     return 0;
     10 }

或者:

myhead.h

      1 #ifndef MYHEAD                                                                                              
      2 #define MYHEAD
      3
      4 externvolatile  int a;
      5 extern void show();
      6
      7 #endif

test.c

     1 #include <stdio.h>                                                                                          
      2 #include "myhead.h"
      3 volatile int a=3;
      4 int main(int argc, char *argv[])
      5 {
      6
      7     show();
      8     printf("%d\n",3);
      9     return 0;
     10 }


volatile 必须在两个文件中同时写明。

 

posted on 2012-10-23 16:30  阿加  阅读(164)  评论(0编辑  收藏  举报

导航