我在RS232Dlg.h定义了以下全局变量,
// RS232Dlg.h : header file
//
#define  comEvReceive          2
#define  comInputModeBinary    1
unsigned  char  RcvData[300];
static  int  SavePointer=0;
unsigned char tdata[300];
FILE*    p1;结果BUILD时,出现了以下的错误,我不知道是什么原因,后来我把全局变量放到RS232.CPP中,结果竟出现变量未定义的错误提示,能帮小弟一把吗?谢先!
Linking...
RS232Dlg.obj : error LNK2005: "unsigned char *  RcvData" (?RcvData@@3PAEA) already defined in RS232.obj
RS232Dlg.obj : error LNK2005: "unsigned char *  tdata" (?tdata@@3PAEA) already defined in RS232.obj
RS232Dlg.obj : error LNK2005: "struct _iobuf *  p1" (?p1@@3PAU_iobuf@@A) already defined in RS232.obj
Debug/RS232.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.RS232.exe - 4 error(s), 0 warning(s)

解决方案 »

  1.   

    定义放在RS232Dlg.cpp, and declare them as extern variables in RS232Dlg.h
      

  2.   

    我就是定义RS232Dlg.cpp,就出现上述错误。
    to Cline(营营) :
    怎么declare them as extern variables in RS232Dlg.h?
    跟定义有什么区别?!
      

  3.   

    //RS232Dlg.cpp
    unsigned  char  RcvData[300];
    static  int  SavePointer=0;
    unsigned char tdata[300];//RS232Dlg.hextern unsigned  char  RcvData[];
    extern static  int  SavePointer;
    extern unsigned char tdata[];
      

  4.   

    to Cline(营营) :
    好像还不行!thank you all the same!
      

  5.   

    试试Build->clean,然后Buile->Rebuild All