Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 140131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:33:34+00:00 2026-05-11T07:33:34+00:00

I’m creating a C++/CLI wrapper DLL that depends on numerous C++ static libraries. Some

  • 0

I’m creating a C++/CLI wrapper DLL that depends on numerous C++ static libraries. Some of the function calls expect unmanaged pointers to be passed in. How do i pass them properly?

Also, other functions expect a ‘this pointer’ to be passed in as a void*. What’s the right way to pass ‘this’?

Here’s my class definition…

public ref class RTPClient {     public:         RTPClient();         ~RTPClient();          bool Connect();         void Disconnect();      private:         CIsmaClient* mClient; }; 

Here’s my usage where the pointers in question are used…

RTPClient::RTPClient():     mClient(NULL) {     CIsmaClient::Create(&mClient, NULL, &AllocBuffer, &GetDataPointer, this); } 

The usage of &mClient and ‘this’ cause the following compiler errors… 1>.\VBLoadSimulatorDll.cpp(40) : error C2664: ‘CIsmaClient::Create’ : cannot convert parameter 1 from ‘cli::interior_ptr’ to ‘CIsmaClient **’ 1> with 1> [ 1> Type=CIsmaClient * 1> ]

1>.\VBLoadSimulatorDll.cpp(40) : error C2664: ‘CIsmaClient::Create’ : cannot convert parameter 5 from ‘VBLoadSimulator::RTPClient ^const ‘ to ‘VOID *’

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:33:35+00:00Added an answer on May 11, 2026 at 7:33 am

    If you are passing a pointer to a managed class then it is easy to convert the ^ reference into a pointer but you must pin the managed object so that the GC doesn’t move it about in memory (thus invalidating the pointer)

    This is simple with pin_ptr

    However your code is doing two things which won’t work

    RTPClient::RTPClient():         mClient(NULL) {     CIsmaClient::Create(         &mClient,          // 1         NULL,          &AllocBuffer,          &GetDataPointer,          this);            //2 } 

    1) You are trying to take the address of something on the managed heap (the location of the pointer to the pointer mClient is on the managed heap.

    As such it can move in memory, thus the compiler supplier interior pointer (whose value is maintained over GC operations). This needs to be pinned and this will only work if the Create function does not expect to use the pointer after it’s scope has ended (if it passes it anywhere else to store it this will lead to bugs).

    2) You are passing a handle (the funny hat symbol) rather than a pointer. (Read the wikipedia section on these they are a good overview) This is not (and cannot) be understood by the unmanaged code.

    The only reason I can think of for this parameter in this context is as an explicit state variable passed to subsequent function callbacks (correct me if I’m wrong). ‘this’ in this context is NEVER going to work properly since this can move about in memory once the pin_ptr goes out of scope.

    With that in mind here is a (partially) corrected implementation making it clear what can and can’t be fixed.

    RTPClient::RTPClient():         mClient(NULL) {     // make it clear you want the address of the instance variable     pin_ptr<CIsmaClient*> pinnedClient = &this->mClient;      CIsmaClient::Create(         pinnedClient,          // fixed         NULL,          &AllocBuffer,          &GetDataPointer,          x /* pass something else in */);            //2 } 

    If you supply more information on what the last parameter is used for I can suggest possible solutions

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 110k
  • Answers 110k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Some thoughts on this You use a GET request. I… May 11, 2026 at 9:33 pm
  • Editorial Team
    Editorial Team added an answer The compile-time error is probably there because you haven't #define… May 11, 2026 at 9:33 pm
  • Editorial Team
    Editorial Team added an answer SPFieldCollection.AddFieldAsXml() is the way to go as far as I… May 11, 2026 at 9:33 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.