Talk About Network

Google





Programming > C - C++ Learning > Re: LNK2005
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 4 Topic 4219 of 4400
Post > Topic >>

Re: LNK2005

by "Jeff Baker" <algorthjb@[EMAIL PROTECTED] > Jul 27, 2008 at 03:03 PM

"Ben Bacarisse" <ben.usenet@[EMAIL PROTECTED]
> wrote in message 
news:87wsj75jaf.fsf@[EMAIL PROTECTED]
> "Jeff Baker" <algorthjb@[EMAIL PROTECTED]
> writes:
>
>> I have two cl***** with two headers respectively and a single header, 
>> just
>> function, that both Implementation Method uses.
>> One header with Implementation Method alone with the function header 
>> works
>> fine. I test both cl***** alone and they work.
>
> So you have:
>
>   a.h:                         b.h:
>
>   class A  {                   class B {
>       ...                          ...
>   };                           };
>
> and a file f.h that is supposed to declare some functions used by
> both:
>
>   a.cc:                        b.cc:
>
>   #include "a.h"               #include "b.h"
>   #include "f.h"               #include "f.h"
>
>>  Combining them I get: Wieghts and Measures 7.25.08 error LNK2005:
"void
>> __cdecl clrscr(int,int,int,int,int)" (?clrscr@[EMAIL PROTECTED]
) already 
>> defined
>> in Grams_Method.obj
>> The link error refers to the header that is function that both cl***** 
>> use.
>> This function header is only included in the Implementation Methods.
>
> If I've got that right, then it looks like f.h defines rather than
> declares clrscr.  One way or another there are two copies of the
> definition of the function.
>
> If this is not enough to sort it out, cut down the code as much as you
> can (without losing the error, of course) and post it.

I found that /FORCE works giving just a warning.  What it does is /FORCE 
only one copy to be used with the other copie(s) being ignored. Gives a 
LNK4006 warning.

I am thinking of writting a class for the function header and embed the 
objects to access the functions. Right now /FORCE works.

Jeff
 




 4 Posts in Topic:
LNK2005
"Jeff Baker" &l  2008-07-27 13:01:41 
Re: LNK2005
Ben Bacarisse <ben.use  2008-07-27 18:27:52 
Re: LNK2005
"Jeff Baker" &l  2008-07-27 15:03:31 
Re: LNK2005
Ben Bacarisse <ben.use  2008-07-27 21:50:14 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Thu Jan 8 12:58:58 PST 2009.