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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:30:50+00:00 2026-05-11T22:30:50+00:00

I have no idea if this is possible, but if it is, what would

  • 0

I have no idea if this is possible, but if it is, what would the syntax look like?

If not possible, why not?

  • 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-11T22:30:50+00:00Added an answer on May 11, 2026 at 10:30 pm

    You should be able to bind to a message implementation (IMP), which are just plain C functions with two hidden parameters, self and _cmd of types id and SEL respectively.

    EDIT: Just tested the following complete example, and it appears to work.

    #include <stdio.h>
    #include <boost/bind.hpp>
    #include <Foundation/NSObject.h>
    
    @interface MyClass : NSObject
    {
    }
    -(int) doSomething:(int)arg;
    @end
    
    @implementation MyClass
    -(int) doSomething:(int)arg
    {
      printf("doSomething: self=0x%08x _cmd=0x%08x\n", self, _cmd);
      return arg + 1;
    }
    @end
    
    int main(void)
    {
      MyClass *myObj = [[MyClass alloc] init], *otherObj = [[MyClass alloc] init];
      typedef int (*MyFunc)(id, SEL, int);
      SEL doSomething_sel = @selector(doSomething:);
      MyFunc doSomething_impl = (MyFunc)[myObj methodForSelector:doSomething_sel];
    
      // bind self & _cmd arguments:
      // calls [myObj doSomething:x]
      int result = boost::bind(doSomething_impl, myObj, doSomething_sel, _1)(14);
      printf("result1: %d\n", result);
    
      // bind _cmd & arg:
      // calls [otherObj doSomething:3]
      result = boost::bind(doSomething_impl, _1, doSomething_sel, 42)(otherObj);
      printf("result2: %d\n", result);
    
      return 0;
    }
    

    With GNUstep, compile as:

    gcc objcbind.mm -o objcbind -I/usr/include/GNUstep -lobjc -lstdc++ -lgnustep-base
    

    On Mac OS X, compile as:

    gcc objcbind.mm -o objcbind -framework Foundation -lstdc++
    

    Output:

    doSomething: self=0x01a85f70 _cmd=0x00602220
    result1: 15
    doSomething: self=0x01a83d70 _cmd=0x00602220
    result2: 43
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have no idea if this is possible ... but it would be cool.
I have no idea how this works or if it is even possible but
I have no idea if this is possible but is there a way in
I have no idea of this is actually possible, but i want the device
So not sure if this is possible but I have a pretty complex form.
Is this possible at all? The idea is to have the following: if ($some_statement)
So I have this idea for a RubyGem that I think would be an
I have no idea if this question fit to SO, but if it doesn't
I have no idea why this doesn't work, but doing some validation functions and
I have no idea what this means. But here is the code that it

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.