Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature to allow multiple translation unit compilations of generated pure headers#1141

Open
DrizztDoUrden wants to merge 1 commit into
hsutter:main from
DrizztDoUrden:dev
Open

Feature to allow multiple translation unit compilations of generated pure headers #1141
DrizztDoUrden wants to merge 1 commit into
hsutter:main from
DrizztDoUrden:dev

Conversation

@DrizztDoUrden

@DrizztDoUrden DrizztDoUrden commented Jun 24, 2024

Copy link
Copy Markdown

The purpose of this PR is to allow including pure headers into multiple translation units without ODR violations.

First and foremost it splits phase2_func_defs into phase2_inline_defs and phase3_regular_defs. Produced .h file gets all declarations (as before), alias definitions and anything template-related, while the rest go to .hpp.

A flag -tu-compatible-h2 is added that stops generated hpp files from including other hpps as it is not necessary to produce a buildable source, but the default behaviour is unchanged. When using the flag it is important to include the resulting .hpp at least somewhere as it is never included automatically.

With a simple-ish cmake functions it makes it possible to produce automatically both header with declarations and inline definitions and a cpp with non-inline definitions. As an example, in my hobby project cmake parses h2s, finds #cppinclude lines and adds them to a new .cpp as regular #include, than includes the generated .hpp.

Green-Sky, epaul13, and LT2H reacted with thumbs up emoji

hsutter commented Sep 25, 2024
edited
Loading

Copy link
Copy Markdown
Owner

Thanks for the suggestion and investing the time to provide code! I may have cycles to take a look at this but for now I'm putting it in bucket 4 in the current priorities (#1287) as I'm taking a pass to triage the outstanding PRs -- I think this is something desirable that we'll need to address somehow at some point. Thanks again.

Copy link
Copy Markdown

@DrizztDoUrden I would like to try this feature, would you mind sharing an example project with me? Thanks.

MatthieuHernandez commented Mar 31, 2025
edited
Loading

Copy link
Copy Markdown
Contributor

Will this feature avoid having to do this? #594 (comment)

epaul13 reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /