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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:55:02+00:00 2026-05-21T14:55:02+00:00

I have two libraries (third-party), and within each of these libs they have defined

  • 0

I have two libraries (third-party), and within each of these libs they have defined two classes with same name (in header files).

// Lib A, HeaderA.h
struct mycompare
{
//Some code
};

// Lib B, HeaderB.h
struct mycompare
{
//Same code
};

Please note that, in both libs, mycompare name and the implementation is same. How to use both header files same time ?

  • 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-21T14:55:03+00:00Added an answer on May 21, 2026 at 2:55 pm

    Assuming you can’t edit the headers/libraries:

    • indirection: create your own out-of-line wrapper for the simpler of A and B, which includes HeaderA.h or HeaderB.h only in the implementation.
      • this is similar to but much less work and coupling than Als’s option 2 😉
    • shameless hackery: include HeaderA.h, then #define mycompare mycompare_duplicate before including HeaderB.h, then #undef mycompare. This could bite you if one of the implementations later changes, and may not be possible if the header later uses the symbol itself (e.g. as a function argument, where type name-mangling would differ and prevent your calls being resolved).

    If you can edit the libraries, then obviously the best long-term option is to put their functionality into separate namespaces.

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

Sidebar

Related Questions

I have two third-party libraries occasionally having the same symbol name exported. When the
I currently have a project that links to two third party libraries. These libraries
I have an application I'm working on that uses two third party libraries, each
I have a problem, where I have two third party libraries classes that I
I have a project that uses two third party libraries, both of which make
I have a project that needs to incorporate two third-party libraries, libA and libB.
Let's say that I have two libraries (A and B), and each has one
I have a project that uses two independent Android libraries. Each of them contains
Suppose I have two classes with identical members from two different libraries: namespace A
I have two identical classes with different properties and in different libraries. I reference

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.