Menu

Visual Studio compiling with "/clr" support.

2009-08-06
2013-04-08
  • Brent Arias

    Brent Arias - 2009-08-06

    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?

     
    • Brent Arias

      Brent Arias - 2009-08-06

      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...

       
    • Brent Arias

      Brent Arias - 2009-08-06

      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...

       
    • Brent Arias

      Brent Arias - 2009-08-06

      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.

       

Log in to post a comment.