Original Post
I've got a piece of code that looks like this: When I link, the constructor at the bottom of this source file is never called. Amazingly, if I build it into a DLL, it does link in and is called, but if this code is compiled into a static library or directly into an exe project, it's discarded. I was wondering if anybody knew what the option was to keep this from going away? I tried the "Keep Unreferenced Data (/opt:noref)" and that doesn't work. I have a more complete working example of the problem if you think this is a challenge for you. :D
#include <iostream>
#include "mylib.h"
class MyClass
: public IMyClass
{
public:
virtual void Hello()
{
std::wcout << L"Hello, world!" << std::endl;
}
};
factory<MyClass> myFactory();