Is it possible? Dumping preprocessor state at end of output so that preprocessing can be resumed?

Open
#237 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp
Domain
compilers

Research direction

Start by reviewing Boost.Wave's context state and preprocessing entry points, focusing on which state the issue proposes to represent as #defines or #pragmas. Determine whether that state can be dumped and restored for a later preprocessing pass; done means a documented feasibility result and usage path, or a clearly scoped implementation plan.

Written by the indexing model from the issue text.

Description

Context

A bit of context to what we're doing.

We have a header-only library of HLSL (shading language resembling C++), where we use Boost Preprocess (BOOST_PP) to get around some ecosystem issues (lack of variadic templates, injecting a bit of reflection, etc.) and most fundamentally the DirectX Shader Compiler being based off Clang 3.7 meaning the preprocessor implementation is really old (no VA_OPT etc).

The problem with shading languages is that nobody has really developed a linker, so every shader compilation is what one would call a "Unity Build".

Now Boost.Wave isn't exactly a speed demon, and using BOOST_PP certainly doesn't help.

We also spice it up even more, by exploiting the fact that HLSL is "almost syntax compatible" with C++ and we often write headers containing algorithms (lower bounds, upper bounds, FFTs) that compile both as C++ and HLSL.

This Nabla HLSL STL is about 16000 LoC.

Due to this insane combo, it loves to crash Intellisense because Intellisense's preprocessor isn't exactly C++20 compliant.

What we're trying to get

We're trying to make the equivalent of PCH but for preprocessing.

This is both to make the further HLSL compilation (including residual preprocessing) faster, but also to cut a break to language servers like Intellisense (especially important when code is shared with C++) and get an overall better source-browsing experience. For example see our nasty reflection-struct defining macro:

NBL_HLSL_DEFINE_STRUCT((MyStruct),
    ((a, float32_t))
    ((b, int32_t))
    ((c, int32_t2))
);

Wouldn't it be nice to actually see the code that generates?

Question

If it possible to dump all of Boost.Wave's context state in the form of #defines (and #pragmas if the state is more complex than can be represented with defines - but not that at least for headers we use guards) at the end of a file.

And if yes, how?

Dominant language
C++
Stars
29
Forks
55
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/wave

All issues in boostorg/wave

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.