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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:08:51+00:00 2026-05-26T20:08:51+00:00

I am currently developing a C program depending on a third-party library with a

  • 0

I am currently developing a C program depending on a third-party library with a C interface (the header files are written in C). I compile my program by linking all the required .so files, and everything is fine. However, I recently take a peek at the source code of this third-party library. Apparently, it is written in C++ and it does utilize some C++ features (namespaces, OOP, and so on).

Is this even possible? So I can write a library in C++, provide a C interface, generate .so files to hide C++ implementation, and then my library can be used within a C program? Will it cause problems?

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. Editorial Team
    Editorial Team
    2026-05-26T20:08:51+00:00Added an answer on May 26, 2026 at 8:08 pm

    Yes.
    The library is written in C++ but it provides an interface which uses C linkage so as to link to your c program.
    This is essentially possible because C++ Standard specifically provides provision to specify the Linkage Specification for a C++ program.

    For Example:

    extern "C" 
    {    
        void doSomething(char);    
    } 
    

    extern "C" here is the linkage specification it makes the function doSomething() in C++ have ‘C’ linkage (compiler does not do C++ style1 Name Mangling) this ensures that your C code can link to it.
    Since the C++ function definition was already compiled and converted to binary format the client application/library ‘C’ linker just links to this code using the ‘C’ name.

    1 An example of difference in Name Mangling for C and C++:
    C++ supports Function overloading while C does not, So the C++ compiler needs to mangle the name by adding information about the function arguments arguments. A C compiler does not need to use the function arguments to mangle the name since there is no function overloading support.When you use the extern “C” linkage Linkage specification, the C++ compiler does not add function argument information to the name used for linkage.

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

Sidebar

Related Questions

Thanks in advance for all of your help! I am currently developing a program
I am currently developing a program in Qt and it uses the library libqextserialport.1.dylib.
I'm currently developing some web application written in Haskell. All Haskell libraries are statically
I am currently developing a program that uses C#'s Dictionary container (specifically, SortedDictionary). This
I am currently developing a library and a set of programs using this library,
Im currently developing a program that uses a scrollable/zoomable image as the main user
I'm currently developing a program that will generate reports based upon lead data. My
Currently am developing a program that solves (if possible) any given labyrinth of dimensions
I'm currently developing a program in Java where a certain event must be triggered
Currently I am developing a program for academic purpose. We use Turbo C because

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.