Re: Union of structs in C#

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Try reading this and see if it helps.

http://blogs.msdn.com/jaredpar/archive/2005/05/13/417263.aspx

--
Jared Parsons [MSFT]
jaredpar@xxxxxxxxxxxxxxxxxxxx
http://blogs.msdn.com/jaredpar
"This posting is provided "AS IS" with no warranties, and confers no rights"
"bazooka" <bazooka.1v1h22@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:bazooka.1v1h22@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> How far is it possible to handle unmanaged C++ declarations of unions in
> C#?? A struct with a union is resolved with
> [StructLayout(LayoutKind.Explicit)] and [FieldOffset(pos)] but what
> about this one??
>
> typedef Byte Bits;
>
> typedef union
> {
> struct {
> Bits queue :4; /* Network interface message
> queue */
> Bits q_cmd :4; /* Network interface command
> with queue */
> Bits length :8; /* Length of the buffer to
> follow */
> } q; /* Queue option
> */
> struct {
> Byte cmd; /* Network interface command
> w/o queue */
> Byte length; /* Length of the buffer to
> follow */
> } noq; /* No queue option
> */
> } NI_Hdr;
>
> Is there a solution in C# managed code??
>
>
> --
> bazooka
> ------------------------------------------------------------------------
> bazooka's Profile: http://www.highdots.com/forums/m667
> View this thread: http://www.highdots.com/forums/t2912328
>


.



Relevant Pages

  • Re: Why does Platform SDK define union LARGE_INTEGER in such a way?
    ... ntdef.h defines the union LARGE_INTEGER as follows: ... typedef union _LARGE_INTEGER ... I suppose the idea is that you can declare ...
    (comp.lang.c)
  • Re: Extending unions and ABI?
    ... typedef struct foo_t { ... Note that I only use pointers to the union in the public api. ... typedef union foobar_t foobar_t; ... because if not I see no advantage in the union compared to using a void pointer together with the individual structs. ...
    (comp.lang.c)
  • Re: Extending unions and ABI?
    ... typedef struct foo_t { ... different types of data (e.g. either a foo or a bar struct) back to the ... Note that I only use pointers to the union in the public api. ... typedef union foobar_t foobar_t; ...
    (comp.lang.c)
  • Re: sizeof a union
    ... >> give a union SU define as: ... >> typedef union _SU ... > members, but you haven't actually declared the second member. ... > have a struct declaration (I don't think that's even legal in this ...
    (comp.lang.c)
  • Re: Union of structs in C#
    ... A struct with a union is resolved with and but what about this one?? ... with queue */ ... Rob ...
    (microsoft.public.dotnet.framework.interop)