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 870273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:26:44+00:00 2026-05-15T10:26:44+00:00

I am trying to figure out the syntax to register a callback with this

  • 0

I am trying to figure out the syntax to register a callback with this 3rd party software. I think it is probably a basic question, I just am not too familiar with c++. They have a method for registering a callback function so their code can call a function in my code when an event happens. They provided a working example that registers the callback from the main file, but I want to know how to do it when working inside a class

Their method signature:

smHTRegisterHeadPoseCallback(smEngineHandle engine_handle, void *user_data, smHTHeadPoseCallback callback_fun);

Working example from the main file:

void STDCALL receiveHeadPose(void *,smEngineHeadPoseData head_pose, smCameraVideoFrame video_frame)
{
 ...
}

void main()
{
 ...
 smHTRegisterHeadPoseCallback(engine_handle,0,receiveHeadPose)
 ...
}

But I want to use this from my class

MyClass.h

class FaceEngine
{
public:
 void STDCALL receiveFaceData(void *, smEngineFaceData face_data, smCameraVideoFrame video_frame);
    ...

MyClass.cpp

void FaceEngine::Start(void)
{
 rc = smHTRegisterFaceDataCallback(hFaceAPIEngine,0,&FaceEngine::receiveFaceData);
        ...

Results in this compiler error:

Error 1 error C2664: 'smHTRegisterFaceDataCallback' : cannot convert parameter 3 from 'void (__stdcall FaceEngine::* )(void *,smEngineFaceData,smCameraVideoFrame)' to 'smHTFaceDataCallback' d:\stuff\programming\visual studio 2008\projects\tut02_vertices\faceengine.cpp 43 Beard

If my question isn’t clear please let me know how I can clarify.

  • 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. Editorial Team
    Editorial Team
    2026-05-15T10:26:45+00:00Added an answer on May 15, 2026 at 10:26 am

    You need to use a trampoline function as member functions can’t be called without an instance:

    void STDCALL trampoline(void* data, smEngineHeadPoseData hp, smCameraVideoFrame vf) {
        static_cast<FaceEngine*>(data)->receiveFaceData(hp, vf);
    }
    
    // ... register:
    smHTRegisterFaceDataCallback(hFaceAPIEngine, static_cast<void*>(this), &trampoline);
    

    Note that this uses the user-data parameter to pass the this pointer, so the trampoline function knows what instance to call the member function on.

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

Sidebar

Related Questions

In trying to figure out this problem (which is still unsolved and I still
I'm basically trying to figure out the simplest way to perform your basic insert
I am trying to figure out this: c = 1 def f(n): print c
Trying to figure out an equation to get the current group a page would
I'm trying to figure out how big a certain database would be (it hasn't
I'm trying to figure out why the control does not honor ZIndex. Example 1
I've been trying to figure out a regex to allow me to search for
I'm trying to figure out how to detect the type of credit card based
I'm trying to figure out what a Java applet's class file is doing under
I am trying to figure out how to click a button on a web

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.