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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:27:40+00:00 2026-05-19T01:27:40+00:00

I’ve got some code originating from a DSL that needs to be translated for

  • 0

I’ve got some code originating from a DSL that needs to be translated for a C++ caller. I need to figure out how to sort #include dependencies in C++. Fortunately, I have a few restrictions that can make my task easier:

  1. The result contains no templates or macros. I can use templates or macros to make my life easier, but the DSL doesn’t explicitly generate anything that requires them- all preprocessing, code generation is taken care of on that end.
  2. The resulting code doesn’t have to be readable or maintainable at all- it’s going to be both produced and consumed by a program. Preferably it would not involve any performance penalties or confuse the optimizers, but I can live if it has to.

However, I have to convert some code that describes programs that are legal C++, but can never be defined, such as

struct X {
    Y y;
    Y func();
};
struct Y {
    X func();
};
// or
struct Y {
    void func(X x);
};
struct X {
    void func(Y y);
};

So far, I came up with the idea that I would make each type it’s own independent header, and then in the implementation file, I can just #include all the types the implementation depends on, which is not going to be too difficult. The issue is how I can mangle the code of X and Y so that this is possible.

Right now, I’ve thought of applying RVO and NRVO, and doing something somewhat similar for arguments. But, aren’t there cases where they’re not just not really optimizations, but not actually possible? This is written in MSVC10 so I can cope with any additional features C++0x has to offer here.

Edit: I edited my code, because I slightly understated my needs. RVO and NRVO also can’t cut this.

Edit edit: I guess that, if forward declarations will suffice for function return values and arguments, I could topologically sort for the include orders of data members. After all, it’s still not legal to do something like

struct X {
    Y y;
};
struct Y {
    X x;
};
  • 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-19T01:27:41+00:00Added an answer on May 19, 2026 at 1:27 am

    Topological sort is the way to go.

    If that doesn’t work, you need to transform your code using shared_ptr or something that relaxes the ordering constraints.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I've got a string that has curly quotes in it. I'd like to replace
i got an object with contents of html markup in it, for example: string
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I have a JSP page retrieving data and when single or double quotes are
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,

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.