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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:21:14+00:00 2026-05-11T13:21:14+00:00

Duplicate of the following question: C function conflict Hi, in my current project I

  • 0

Duplicate of the following question: C function conflict


Hi, in my current project I have to use some kind of interface lib. The function names are given by this interface, what this functions do is developers choice. As far as I can tell a project shall use this functions and when it comes to compiling you choose the lib and with it the functionality. What I try to do is to use an existing lib and my lib at the same time by wrapping the other and call it in mein functions:

otherlib:

int function1 (int a) { // do something } 

mylib:

int function1 (int a) { //my code here     otherlib::function1(a); } 

Problem is I don’t have access to the other lib and the other lib doesn’t have any namespaces. I already tried

namespace old {     #include 'otherlib.h' } 

and then call the old function by old::function1 in my function. This works as long as it’s only header file. The lib exports it’s symbol back into global space. Also something like

namespace new {     function1 (int a) {         ::function1(a);     } } 

didn’t work. Last but not least I tried ifdefs and defines suggested here

but I wasn’t successful.

Any ideas how to solve this? Thanks in advance.

EDIT: I neither have access to the old lib nor the project both libs shall be used in.

EDIT2: at least the old lib is a static one

  • 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-11T13:21:15+00:00Added an answer on May 11, 2026 at 1:21 pm

    Namespaces in C solved using library names prefixes like:

    libfoo –> foo_function1
    libbar –> bar_function1

    These prefixes are actual namespaces. so if you write libbar

    int bar_function1(int a) {      function1(a); } 

    This is the way to solve problems.

    C has namespaces — they just called prefixes 😉

    Another option is to do various dirty tricks with dynamic loading of libraries like:

    h1=dlopen('libfoo.so') foo_function1=dlsym(h1,'function1')  h2=dlopen('libbar.so') bar_function1=dlsym(h2,'function1') 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Decode obfuscated JavaScript Question: I have the following javascript code: var _0xe91d=[\x28\x35\x28\x24\x29\x7B\x24\x2E\x32\x77\x2E
Possible Duplicate: What does this mean? (function (x,y)){…}){a,b); in JavaScript I have the following
I have below a function (from a previous question that went unanswered) that creates
Possible Duplicate: C++ virtual function from constructor Calling virtual functions inside constructors This question
Possible Duplicate: Some issues trying to read a file with cbc.read.table function in R
Possible Duplicate: how to provide a swap function for my class? There are some
Duplicate : Function overloading by return type? Maybe this is a very silly question
Following up on this question , it seems that the duplicate issue could be
Possible Duplicate: Sizeof array passed as parameter Given the following code, the system I'm
Duplicate question of this . I have a class like this: template <class T>

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.