Click to Rate and Give Feedback
MSDN
MSDN Library
Networking
Network Protocols
Overviews
Arrays and Pointers
Pointers and RPC
 Default Pointer Types
This page is specific to
.NET Framework 3.0

Other versions are also available for the following:
Default Pointer Types

Pointers are not required to have an explicit attribute description. When an explicit attribute is not provided, the MIDL Compiler uses a default pointer attribute.

The default cases for unattributed pointers are the following:

  • Top-level pointers that appear in parameter lists default to [ref] pointers.
  • All other pointers default to the type specified by the [pointer_default] attribute. When no [pointer_default] attribute is supplied, these pointers default to the [ unique ] attribute when the MIDL compiler is in Microsoft Extensions mode or the [ptr] attribute when the MIDL compiler is in DCE-compatible mode.

When a remote procedure returns a pointer, the return value must be a [ unique ] or full ([ ptr ]) pointer.

/* IDL file compiled without /osf */
[ 
  uuid(ba209999-0c6c-11d2-97cf-00c04f8eea45),
  version(1.0),
  pointer_default(ptr)
]
interface MyInterface
{
    typedef long *PLONG;
  
    struct MyCircularList {
        struct MyCircularList *pRight;
        struct MyCircularList *pLeft;
        long Data;
    };

    void Foo1( [in] PLONG p );                   // p is ref
 
    void Foo2( [in] struct MyCircularList *p );  // p is ref, p->pRight and p->pLeft is ptr

    struct MyCircularList *Foo3( void );         // returned pointer is ptr.    
}

[ 
  uuid(ba209999-0c6c-11d2-97cf-00c04f8eea46),
  version(1.0)
]
interface MyInterface2
{
    struct MySingleList
       {
       struct MySingleList *pNext;
       long Data;
       };
    void Foo4( [in] struct MySingleList *p );  // p is ref, p->pNext is unique

    struct MySingleList *Foo5( void );         // returned pointer is unique.    
}

Remarks

To ensure unambiguous pointer-attribute behavior, always use explicit pointer attributes when defining a pointer.

It is recommended that [ptr] is used only when pointer aliasing is required.

Send comments about this topic to Microsoft

Build date: 5/28/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker