Argg!! I can't fix this error
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.
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]
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]
Try to put this on your file "OneDfish.h"
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
#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
Popular Topics
Advertisement