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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:04:30+00:00 2026-06-02T12:04:30+00:00

I am trying to use some old C libraries in some new C++. The

  • 0

I am trying to use some old C libraries in some new C++.

The library’s header files use D. Hanson’s “C Interfaces and Implementations” implementation-hiding idiom of:

#define T MyAST 

typedef struct T *T;

Near as I can tell, this compiles with C because in C struct names and typedef names are in different namespaces but it does not compile with C++ (extern "C" { #include "MyAST.h" }) evidently because typedef and struct names are in the same namespace.

conflicting declaration 'typedef struct MyAST* MyAST'

I think I’m doomed to move the struct def into the headers and give up using the technique but I really don’t want to (this idiom is used in a lot of code, some mine, some not) and thought I’d check here to see if anyone has any insight.

PS: If you don’t know the idiom, it lets you keep the struct definition in the implementing C file and then users of the interface (MyAST.h) can’t reach into the struct, they must use your functions in the implementation.

  • 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-02T12:04:32+00:00Added an answer on June 2, 2026 at 12:04 pm

    Honestly if the only purpose here is to use some old libraries (which we’ll presume won’t be updated), I’d create a glue layer between your C++ and the old libraries. Just write a small amount of wrapper code that’s compiled in C to use the old libraries, and provide a C interface that compiles in C++ to your new C++ code.

    Having the same name mean two different things can only cause confusion among future maintainers, so I would try to isolate the interface code to a few source files.

    Finally, while I can appreciate wanting to separate the interface from the implementation at some point you have to trust your code users to not flagrantly violate the conditions of the library and just code it in an obvious way rather than going to paranoid lengths to hide struct definitions away.

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

Sidebar

Related Questions

I'm trying to use some of the new MFC feature pack controls on an
I'm trying to use some of the functions that are in the /lib/libproc-3.2.6.so library
I am new to jquery, with some basic understanding. I am trying to use
I'm trying to follow some old C++ tutorial which use old version o wxWidgets
From some old c++ code im trying to use a com dll, it works
Trying to update some old code from live() to use on() and something is
I'm just trying to use some basic Isolated Storage functionality and I keep getting
I'm trying to use some data from a PlanPlusOnline account. They only provide a
I am trying to use some pinvoke code to call a C function. The
I am trying to use some Word 2007 automation where we give the user

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.