CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004
    Posts
    4

    Question Unmanaged struct

    I am getting the following compile error:

    E:\Computer Work\C#\Projects\SharpVorbis\Class1.cs(103): Cannot take the address or size of a variable of a managed type ('SharpVorbis.Ogg_H.oggpack_buffer')

    Add line 103 is:
    public static extern void oggpack_writetrunc(oggpack_buffer *b, long bits);

    The definition of oggpack_buffer is:
    unsafe struct oggpack_buffer
    {
    long endbyte;
    int endbit;

    string buffer;
    string ptr;
    long storage;
    }
    (The unsafe is there because i was trying to make it unmanaged

  2. #2
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890

    Re: Unmanaged struct

    public static extern void oggpack_writetrunc(oggpack_buffer *b, long bits);

    if you know the size here you can allocate size and then get value,
    otherwise use ref keyword
    like

    public static extern void oggpack_writetrunc(ref oggpack_buffer b, long bits);

    regards
    Paresh.
    - Software Architect

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured