...but the Singleton.cpp file I included in my make did not have that #define statement. It caused its translation unit to have a Mutex of a different size. Without the /clr switch, that problem goes undetected.
So I made a local copy of Singleton.cpp in my VS project, and changed its #include statement to point to my own header that was giving the #define. Problem solved.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can make a Loki singleton with Common Language Runtime (CLR) support as long as I use single threading. This is fine:
typedef SingletonHolder<CryptoForm, CreateUsingNew, DefaultLifetime> Crypto;
...but the moment I add in ClassLevelLockable, I get this error:
error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (Loki.Mutex): (0x02000053). Singleton.obj LMAdaptRsa
I have "Singleton.cpp" added directly to my VS "LMAdaptRsa" project (it is not pre-built).
Any ideas?
I forgot to mention: I'm building with VS 2k8, SP1.
p.s. how do I search these forums? I don't see an option...
I forgot to mention: I'm building with VS 2k8, SP1.
p.s. how do I search these forums? I don't see an option...
Ok, with the help of this article:
http://blogs.msdn.com/vcblog/archive/2007/05/17/diagnosing-hidden-odr-violations-in-visual-c-and-fixing-lnk2022.aspx
...I found the problem. My header that was declaring my contained type (and a SingletonHolder typedef) had this:
#define LOKI_CLASS_LEVEL_THREADING
#include <loki/singleton.h>
...but the Singleton.cpp file I included in my make did not have that #define statement. It caused its translation unit to have a Mutex of a different size. Without the /clr switch, that problem goes undetected.
So I made a local copy of Singleton.cpp in my VS project, and changed its #include statement to point to my own header that was giving the #define. Problem solved.