The problem is that g_list (line 28) is apparently being defined multiple times, though I am using extern. The code below is in a statically linked library (libsimcom.lib). g_list is supposed to be shared between each .obj that uses it, so that anyone can use SetAfterDelay() to "add" an object to the list and the executive module can use ManageDelays() to follow-up on each object. Does anyone have an idea?
#ifndef TIMER_H
#define TIMER_H
#include <vector>
namespace wa7vasxh // Arbitrary strange name to avoid conflicts and to protect the inner members from being in global scope
{ // These functions are not intended for use outside of this library
struct CountDownObject
{
public:
float m_timeLeft;
virtualbool timeExpired(float dt) = 0;
};
template <typename T>
class DelayObject : public CountDownObject
{
private:
//...
public:
DelayObject( T* lpLabelAddress, float delay, T target) { /*...*/ }
// Decrements the timer and sets everything if required
// Returns TRUE if the time has expired. If this has happened, clean up DelayObject as it's useless now.
virtualbool timeExpired(float dt) { /*...*/ }
};
extern std::vector<CountDownObject*> g_list; // When other .objs include this file, they have a problem right here!
};
template <typename T>
void SetAfterDelay( T* lpLabelAddress, float delay, T target = T(1) )
{
wa7vasxh::g_list.push_back(new wa7vasxh::DelayObject<T>(lpLabelAddress, delay, target) );
}
void ManageDelays(float dt);
#endif //TIMER_H
I dont see any errors relating to g_list, how did you come to that conclusion?
I do see 4 errors about std::string though, constructor/destructor/c_str() (actually 2 constructors)
try running LIB / LIST to see what is in your libsimcom.lib, i think you will find stdlib has been statically linked with it and that is causing the clash with MSVCP90.dll.
from the errors you have listed it looks like std::string appears in your current application that you are building and also in your other project libsimcom.lib
Thanks, I'll figure out my problems with the statically linked standard library. This answers my question! I just assumed it was a problem with g_list because that was the only object that was declared.