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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:08:54+00:00 2026-06-10T20:08:54+00:00

I have gotten 2 header files that I include that both have typedef of

  • 0

I have gotten 2 header files that I include that both have typedef of the same name.

Let’s say aaa.h and bbb.h. They came from 2 unrelated 3rd party packages and I have no control of these 2 files but have to use them. I don’t include both file directly but they are rather sub-included in the top level header file. (ie. I include a.h and b.h which respectively included them)

My program wont compile when they are both included because of the name conflict.

So my temporary solution is I copied aaa.h into my source tree with only the typedef removed, called myaaa.h. At the top of the file I keep the “#ifndef AAA_H, #define AAA_H” wrapper intact so when I include myaaa.h, aaa.h would not be included because the AAA_H flag is already defined, indirectly removed the typedef conflict.

Is there a cleverer way to do this without adding such file (and I have to version control it) to my source?

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-06-10T20:08:55+00:00Added an answer on June 10, 2026 at 8:08 pm
    #define conflicting_typedef aaa_conflicting_typedef
    #include "aaa.h"
    #undef  conflicting_typedef
    #define conflicting_typedef bbb_conflicting_typedef
    #include "bbb.h"
    #undef  conflicting_typedef
    #define conflicting_typedef ambiguous use aaa_conflicting_typedef or bbb_conflicting_typedef
    

    If you need to refer to the typedef from aaa.h, you can use the name aaa_conflicting_typedef; to refer to the typedef from bbb.h, use the name bbb_conflicting_typedef. If (as is probably the case) you don’t need to refer to either typedef in your code, then you’re good to go. The final #define ensures that you don’t use the plain name; you must use the correct mapped name.

    Clearly, this should not be repeated; if there’s more than one file that needs this stanza, you put it into your own header “aaa_bbb.h” and include that where you need the stanza. You can even detect whether either aaa.h or bbb.h has already been included and reject the compilation if it has (you can’t detect if they’re included after this, but the fact that they’ve been included once under your control means they should not be included again).

    If this was C++, you’d have a bigger problem because of type-safe linkage. OTOH, the library vendors are then both guilty of improper name space control.

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

Sidebar

Related Questions

So I have a site that I need to be functional both on mobile
I have gotten into the habit of declaring structs nested inside the class that
I have two nested div s that are supposed to both be 400 pixels
I have the following files: listDriverTest.cpp src/List.cpp headers/List.h The include in List.cpp is #include
I have gotten the following errors using ruby 1.9.2-p320 with Heroku's Taps-using 'db' commands
I have gotten myself into a catch 22 and cannot seem to find my
I have gotten a great deal of help from KandadaBoggu on my last question
I seem to have gotten confused as to what the css clear keyword means.
I have a client who's wordpress sites have gotten hacked twice by iframe scammers.
I'm new to Java and have gotten myself into a situation where it's evident

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.