locked
error C3980 'blah' cannot be emitted into metadata

    Question

  • I have a regular c++ structure that I'm trying to use in my WinRT C++ / CX component, and I'm getting an undocumented compiler error:

    error C3980: 'blah' cannot be emitted into metadata
    

    Is there a way to tell the compiler to ignore this struct for purposes of metadata?

    Friday, May 18, 2012 10:00 PM

Answers

  • This is just a guess, but hopefully it may be helpful: If the struct appears as a method parameter type on a method that is exposed via Windows Runtime metadata, you'll either need to find an equivalent representation that does conform to the Windows Runtime type system, or hide that method from your Windows Runtime exposed surface area. As long as the struct isn't passed to Windows Runtime methods or marked as a Windows Runtime type, you should be able to leave it as a normal C++ struct.

    Thanks,

    Ben Kuhn

    • Marked as answer by BullyOwner Tuesday, May 29, 2012 4:58 PM
    Thursday, May 24, 2012 2:59 PM
  • I changed the type to be IntPtr.  That makes it work.
    • Marked as answer by BullyOwner Thursday, August 09, 2012 1:13 AM
    Tuesday, May 29, 2012 7:10 PM

All replies

  • Can you show some minimal code that can be used to repro this error?

    http://blog.voidnish.com

    Saturday, May 19, 2012 2:55 PM
  • Not easily.  It's part of a very large project being ported to WinRT.

    I'll try, but what I really need is a way to tell the compiler to ignore this struct b/c it should not be "emitted" anyway.

    Monday, May 21, 2012 1:43 PM
  • You don't have to make it a WinRT component if it's only used internally. Just use it as an ISO C++ struct (no ref or value prefixes in the class definition).

    http://blog.voidnish.com

    Tuesday, May 22, 2012 2:46 PM
  • I am making a WinRT component. But the struct in question does not have value or ref modifiers.
    Tuesday, May 22, 2012 3:19 PM
  • This is just a guess, but hopefully it may be helpful: If the struct appears as a method parameter type on a method that is exposed via Windows Runtime metadata, you'll either need to find an equivalent representation that does conform to the Windows Runtime type system, or hide that method from your Windows Runtime exposed surface area. As long as the struct isn't passed to Windows Runtime methods or marked as a Windows Runtime type, you should be able to leave it as a normal C++ struct.

    Thanks,

    Ben Kuhn

    • Marked as answer by BullyOwner Tuesday, May 29, 2012 4:58 PM
    Thursday, May 24, 2012 2:59 PM
  • Ben, your comment was helpful.  I have found the exact code that causes the problem.  I have in internal property like the following:

          internal: property pCPPSTRUCT Foo { pCPPSTRUCT get(); }
    
    Looks like I will have to find some other way to handle this in WinRT.
    Tuesday, May 29, 2012 4:58 PM
  • I changed the type to be IntPtr.  That makes it work.
    • Marked as answer by BullyOwner Thursday, August 09, 2012 1:13 AM
    Tuesday, May 29, 2012 7:10 PM
  • try declaring CPPSTRUCT as public ref ... etc.

    Giuseppe


    =dg=

    Sunday, June 24, 2012 4:06 PM