[RESOLVED] Managed unions?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: [RESOLVED] Managed unions?

Hybrid View

  1. #1
    Join Date
    Dec 2005
    Posts
    16

    [RESOLVED] Managed unions?

    value struct myStruct
    {
    int myInt;
    };

    union myUnion
    {
    myStruct iShareMyMemory;
    myStruct meToo;
    };


    Results in the error C2848: 'myUnion::iShareMyMemory' : a managed type cannot be a member of a union.


    StructLayout also doesn't seem to work.


    Will this be supported with the next release?
    Share on Google+

  2. #2
    Join Date
    May 2006
    Posts
    22

    Re: Managed unions?

    There are supported today - though it is ugly:

    using namespace System;
    using namespace System::Runtime::InteropServices;

    [ StructLayout(LayoutKind::Explicit) ]
    public value struct MyUnion
    {
    [ FieldOffset(0) ]
    int data1;

    [ FieldOffset(0) ]
    String^ data2;

    [ FieldOffset(0) ]
    Double data3;
    };

    We have no current plans to 'improve' this support.
    Jonathan Caves
    Visual C++ Compiler Team
    Share on Google+

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center