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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:42:28+00:00 2026-06-18T00:42:28+00:00

I have the job to create a shared library which should be useable as

  • 0

I have the job to create a shared library which should be useable as a replacement for several (older) versions of an other shared library.

Now the problem:

I have to combine:

Library a:

const char *mixer_ctl_get_enum_string(struct mixer_ctl *ctl, unsigned int enum_id);
const char *mixer_ctl_get_name(struct mixer_ctl *ctl);

Library b:

int mixer_ctl_get_enum_string(struct mixer_ctl *ctl, unsigned int enum_id, char *string, unsigned int size);
int mixer_ctl_get_name(struct mixer_ctl *ctl, char *name, unsigned int size);

I found out how to handle several amounts of input-params, but now they also have different return-types. I found examples for this in C++, but not for C.

How can I do this?

If C would work like Java, I would just implement both and everything is fine, but in C?

Thanks for your help & kind regards!

  • 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-06-18T00:42:29+00:00Added an answer on June 18, 2026 at 12:42 am

    There is no easy or general solution.

    In C++ you could package up functions into classes, and function names only have to be unique in the class. C doesn’t have this.

    In C++, the return type and types of arguments count as part of a function name (so void foo(int) and void foo(float) are actually different functions and the compiler knows which one to call). C doesn’t have this.

    In C there is a single, global namespace, and the types do not count as part of the function name. As others have noted, the standard C function names are different for different return types: sqrt() returns double but sqrtf() returns float.

    There are functions in C that can take a varying number of arguments; a classic example is printf(). But these are tricky to write, and not a general solution to your problem. In the case of printf() there is a “format string” argument, and the printf() function just has to trust that the format string correctly matches up with the arguments to printf(). (Well, since printf() is common, some compilers actually check the format string against the arguments, but your library functions don’t have this advantage!)

    I’ve done a lot of work in C, and the single global namespace is one of the most annoying limitations of C. Is there any chance that you can actually use C++ for this project? If you use the basic features of C++, you can treat it as “C with classes” and just take advantage of namespaces and function overloading.

    Otherwise I think your best bet is to use a refactor tool, or a really good search-and-replace feature in a text editor, to change the function names to be globally unique. An obvious way to do this is to change every function to have the library name as a prefix:

    const char *a_mixer_ctl_get_name(struct mixer_ctl *ctl);  // library a
    int b_mixer_ctl_get_name(struct mixer_ctl *ctl, char *name, unsigned int size);  // library b
    

    Then you would have to refactor or search-and-replace the programs using the old libraries, but since the libraries are mutually contradictory you should have an easy time getting things working again.

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

Sidebar

Related Questions

I have a problem for create a SQL job, in my local machine I
gcc 4.7.2 Hello, I am trying to create a shared library that uses the
I have a job model which has many attributes. I would like to use
I have cron job - php script which is called one time in 5
I have job insert page which is working fine. I just build an update
I wish to make use of my unlimited shared hosting to create several small
I have simple job to do. I have to create an Help page for
I have created the cron job with whenever (https://github.com/javan/whenever): every 1.hours do rake scrape
I have created a very simple sharepoint timer job. All i want it to
I have a job interview tomorrow and I'm trying to answer this question: There

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.