
Forcing a Link due to LNK2005
Hi,
When is it ok to use the /FORCE option to force a link? I have been getting
a LNK2005 which claims that some symbols were multiply defined. I go ahead
and use the /FORCE option and everything works.
Additional details:
The setup of my project is as follows:
ATL wizard generated app
The main file master.cpp includes the following
#include "stdafx.h"
#include "resource.h"
#include "initguid.h"
#include "Master.h"
#include "Master_i.c"
#include "MasterImp.h" //from my COM object
The header file which contains the definition for my object is called
MasterImp.cpp and include's the following
#include "resource.h" // main symbols
#include "mstraccess.h" //from another COM server. Needed because I
implement a Sink.
#include "mstraccess_i.c"
#include <stdio.h>
MasterImp.cpp has the method definitions and includes the following
#include "stdafx.h"
#include "Master.h"
#include "MasterImp.h"
The above configuration gives me LNK2005 telling me that IID's CLSID's etc.
are defined more than once.
However, if I move the implementation for my methods from the cpp file to
the .h file (I know bad programming practice but STL does it!) everything
compiles when I take masterimp.cpp out of my project.
Am I including improperly? I have left things pretty much the way the ATL
wizard gave them to me except for the mstraccess.h and mstraccess_i.c files.
It seems like I should be able to include mstraccess.h and _i.c without
getting this error.
I guess what I am wondering is if I force it will it cause negative
repercussions down the road?