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

  • Home
  • SEARCH
  • 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 168425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:27:05+00:00 2026-05-11T12:27:05+00:00

I have this program that I want other processes to be able to call

  • 0

I have this program that I want other processes to be able to call functions on (through unix sockets). The message protocol is very simple, the function name, a function signature, and a buffer (char *) that holds the parameters.

When a module in my program wants to allow a function to be accessible, it registers the name and signature with the library. The problem I’m facing is with physically calling the function once the request comes in. I have looked at RPC and java RMI-like libraries, but those require that I generate stubs to wrap calls. The system I am working on is very dynamic and I also have to interface with other peoples code that I can’t modify.

So basically, a function might look like:

int somefunc(int someparam, double another) {     return 1234; } 

now I register with the library:

//           func ptr   name       signature REG_FUNCTION(somefunc, 'somefunc', 'i:id'); 

When the request comes in, I do some error checking, once valid I want to call the function. So I have the variables:

void * funcptr = (the requested function); char * sig = (the function signature); char * params = (a buffer of function parameters); //note that the params buffer can hold data types of arbitrary lengths 

How can I call the function with the parameters in C?

Thanks!

  • 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-11T12:27:05+00:00Added an answer on May 11, 2026 at 12:27 pm

    I don’t think this is completely solvable in general, using only C. You don’t know the calling convention used by the target function, for instance. There is a risk that you end up ‘cheating’ the compiler, or at least having to second-guess it. What if the compiler decided to build the registered function using arguments passed in registers, perhaps due to some optimization setting (or what if it was built with a different compiler?).

    There’s also no way in general to express in C that you want to call a function with a given set of arguments, and that the values for the arguments need to be unpacked from a buffer of random bytes.

    You could do something horrible like this:

    enum { VOID_INT, VOID_INT_DOUBLE, VOID_DOUBLE_INT, ... } Signature;  void do_call(const void *userfunction, const void *args, Signature sig) {   switch(signature)   {     case VOID_INT:     {       int x = *(int *) args;       void (*f)(int) = userfunction;       f(x);       break;     }     case VOID_INT_DOUBLE:     ...   } } 

    But it’s quite clear that this doesn’t live on the same continent as scalability. You could of course auto-generate this code, for some reasonable set of return types and argument types. You’d still be a bit out in the cold for casting function pointers to/from void *, but that might be acceptable. You’d still always run the risk of someone handing you a signature that you don’t have pre-generated code for, though.

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

Sidebar

Ask A Question

Stats

  • Questions 85k
  • Answers 85k
  • 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 I think you still need to call document.createEventObject -- you… May 11, 2026 at 5:13 pm
  • Editorial Team
    Editorial Team added an answer One option is to use Ruby's win32ole library. The following… May 11, 2026 at 5:13 pm
  • Editorial Team
    Editorial Team added an answer Sorting and filtering and WCF have nothing to do with… May 11, 2026 at 5:13 pm

Related Questions

I want to kill a process programmatically in vista/windows 7 (I'm not sure if
(I'm using the pyprocessing module in this example, but replacing processing with multiprocessing should
TL;DR version: I have two threads. One of them might need to Interrupt() the
I have a databases table with ~50K rows in it, each row represents a

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.