Argg!! I can't fix this error

Started by
1 comment, last by Nothingness 21 years, 4 months ago
I have been trying to fix this for a long time. I have a problem which the error says Compiling... OneDfish.cpp TwoDFish.cpp C:\windows\Desktop\fish\OneDfish.cpp(9) : warning C4700: local variable ''fish'' used without having been initialized c:\windows\desktop\fish\functions.h(55) : warning C4700: local variable ''fish'' used without having been initialized C:\windows\Desktop\fish\TwoDFish.cpp(10) : warning C4700: local variable ''fish'' used without having been initialized c:\windows\desktop\fish\functions.h(55) : warning C4700: local variable ''fish'' used without having been initialized Linking... OneDfish.obj : error LNK2005: "int __cdecl Direction1(int)" (?Direction1@@YAHH@Z) already defined in Main.obj OneDfish.obj : error LNK2005: "int __cdecl Direction2(int)" (?Direction2@@YAHH@Z) already defined in Main.obj OneDfish.obj : error LNK2005: "int __cdecl Menu(class FISH)" (?Menu@@YAHVFISH@@@Z) already defined in Main.obj TwoDFish.obj : error LNK2005: "int __cdecl Direction1(int)" (?Direction1@@YAHH@Z) already defined in Main.obj TwoDFish.obj : error LNK2005: "int __cdecl Direction2(int)" (?Direction2@@YAHH@Z) already defined in Main.obj TwoDFish.obj : error LNK2005: "int __cdecl Menu(class FISH)" (?Menu@@YAHVFISH@@@Z) already defined in Main.obj Debug/Main.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe. I made each ''.h'' file with the appropiate headers, and ifndef etc. I made the functions ''extern'' but i don''t know what to do. This never leaves. I cant even start the main programming until I get the intialization to work.
Advertisement
See there.

And don't define non-inline functions in headers. extern doesn't really help for functions, only variables.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | Free C++ IDE. ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Boost C++ Lib ]

[edited by - Fruny on December 9, 2002 9:10:35 AM]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Try to put this on your file "OneDfish.h"

  #if !defined(ONE_FISH_HEADER)#define ONE_FISH_HEADER...   // Your function and variable declarations goes here#endif  


Do the same to "TwoDFish.h" but change the "ONE_FISH_HEADER" to
TWO_FISH_HEADER.

Actually you can give it the name you want, and it means that
the part between the "#if !defined" and "#endif" will only be
declared if it has not been declared before by annother "#include"

Hope it helps

Kamikaze

This topic is closed to new replies.

Advertisement