#ifndef __THISFILE_H__
#define __THISFILE_H__
// all the functions and code here
#endif // __THISFILE_H__
I've tried deleting the temp files, and doing a fresh compile, still the same. I can't figure out how it's linking these functions twice. What am i doing wrong?
*Annoyed*
Edit - Formatting
Edited by - Skibum on November 6, 2001 7:56:38 PM
Linker Error: LNK2005
Using MSVS 6.0 on a windows program
I'm getting this annoying linker error for every function in one of my .h files. In every .h file i have, i have:
You _never_ put anything but inline functions in headers. The header guards are to prevent multiple inclusions from the same .cpp file...eg cpp includes header1 that includes header2 that includes header3 that includes header1. It will not prevent the compiler from seeing multiple globally defined functions.
Put only function _declarations_ in the header files, then put the _definitions_ in one, and only one, cpp file.
"I contend that we are both atheists. I just believe in one fewer god than you do. When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours." - - Stephen Roberts
Put only function _declarations_ in the header files, then put the _definitions_ in one, and only one, cpp file.
"I contend that we are both atheists. I just believe in one fewer god than you do. When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours." - - Stephen Roberts
Only put declarations in header files. Now and forever, until the end of time. Put actual implementation only into source files, now and forever, until the end of time. It''s good that you know how to use multiple inclusion protection, but you need to know what to have it protect
quote:Original post by Skibum
And by this you mean?
He means if you don''t know the difference between a declaration and a definition, you''d best to back up and hit that intro text again.
I wanna work for Microsoft!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement