Note that there are some explanatory texts on larger screens.

plurals
  1. POConvert from C++/CLI pointer to native C++ pointer
    primarykey
    data
    text
    <p>I have run in to this problem of converting a C++/CLI pointer to a native C++ pointer. Heres the background: I'm writing a windows forms application using C++/CLI. The application makes call into a number of COM Interfaces. When creating an instance (inside of a C++/CLR class) of a object through the COM interface, i pass in <code>(void**)(&amp;provider)</code> as the last argument to <code>CoCreateInstance</code>, as in:</p> <pre><code>HRESULT CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, (void**)(&amp;provider)); </code></pre> <p>However, i get the compiler error: cannot convert from <code>cli::interior_ptr&lt;Type&gt;</code> to <code>void **</code> . I've done som research into this, and it looks like it is a problem of different types of pointers in C++ and C++/CLI. Anyone has any knowledge about this, and maybe a tip on how it could be fixed? Thanx in advance!</p> <p>First, thanx for all your help!</p> <p>As Freich suggested, i tried to use the <code>pin_ptr</code>, but this instead made the compiler complaining about problems converting from <code>interior_ptr</code> to <code>pin_ptr</code>. If i instead try to use the <code>interior_ptr</code> as in:</p> <pre><code>pin_ptr&lt;void *&gt; pinnedPtr = &amp;provider; CoCreateInstance(CLSID_MSPRProvider, NULL, CLSCTX_LOCAL_SERVER, IID_IMSPRProvider, ( void** )pinnedPtr); </code></pre> <p>I get cannot convert from <code>interior_ptr</code> to <code>interior_ptr</code>. It all boils down to the problem of converting the <code>interior_ptr</code> to <code>void**</code>. Like this: <code>(void**)interiorPtr</code>, where <code>interiorPtr</code> of course is an <code>interior_ptr</code>. Any ideas in this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload