glideapps / glideapps/quicktype

C++: add a lean-header mode that avoids including nlohmann/json.hpp

Open
#3,095 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
13.9k
Forks
1.2k
Avg merge
8h 53m
Merged PRs (30d)
369

Description

The C++ renderer currently emits `#include ` in generated header-like files. Although the generated code is commonly included from many translation units, this pulls the full nlohmann/json implementation into every compile and significantly increases build time.

The existing `source-style: multi-source` option separates generated types, but the generated headers still depend on the full JSON header. Downstream users have to post-process the output into a forward header, a translation unit, and an implementation include fragment.

Proposal: add a C++ renderer option (for example `--lean-header`) that emits:

- `Fwd.hpp`: standard-library dependencies, `nlohmann/json_fwd.hpp`, generated types, and JSON function declarations.
- `Fwd.cpp`: includes the forward header and the full `nlohmann/json.hpp`, then includes the implementation fragment.
- `.inc`: non-inline JSON helper and serializer definitions.

The default output should remain unchanged. This would make the heavy JSON header a dependency of one implementation translation unit instead of every consumer of the generated types.

Contributor guide

Open the contributing guide

Research direction

Start with the C++ renderer and its existing source-style: multi-source path, then compare the current generated header and implementation outputs. Define how the new lean-header option produces the named Fwd.hpp, Fwd.cpp, and .inc artifacts while preserving default output; done means the full JSON header is limited to the implementation translation unit.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.