header file problem

I've created my own header file in an MFC project. The reason is I want to use some functions for more classes. But the compiler says:

Linking...
ServerDlg.obj : error LNK2005: "unsigned short __cdecl calcChecksum(char const *)" ( calcChecksum@@YAGPBD@Z) already defined in ClientDlg.obj
Zadanie2.obj : error LNK2005: "unsigned short __cdecl calcChecksum(char const *)" ( calcChecksum@@YAGPBD@Z) already defined in ClientDlg.obj
Zadanie2Dlg.obj : error LNK2005: "unsigned short __cdecl calcChecksum(char const *)" ( calcChecksum@@YAGPBD@Z) already defined in ClientDlg.obj


as if the function was defined more than once. But the only reason why this happens is because I have added my header file to all of these classes. How can I solve it
The "stdafx.h" is included more than once and compiler doesn't see a problem in that.

thanks


Answer this question

header file problem

  • S Eisenberg

    myso wrote:
    I've created my own header file in an MFC project. The reason is I want to use some functions for more classes. But the compiler says:

    Linking...
    ServerDlg.obj : error LNK2005: "unsigned short __cdecl calcChecksum(char const *)" ( calcChecksum@@YAGPBD@Z) already defined in ClientDlg.obj
    Zadanie2.obj : error LNK2005: "unsigned short __cdecl calcChecksum(char const *)" ( calcChecksum@@YAGPBD@Z) already defined in ClientDlg.obj
    Zadanie2Dlg.obj : error LNK2005: "unsigned short __cdecl calcChecksum(char const *)" ( calcChecksum@@YAGPBD@Z) already defined in ClientDlg.obj


    as if the function was defined more than once. But the only reason why this happens is because I have added my header file to all of these classes. How can I solve it
    The "stdafx.h" is included more than once and compiler doesn't see a problem in that.

    thanks

    I get the feeling this is related to http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=180949&SiteID=1. Also see http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=163883&SiteID=1.



  • header file problem