Skip to content

feat: Let cpp_register() find the types header in src/include/ - #9

Open
krlmlr wants to merge 1 commit into
f-types-src-includefrom
claude/f-types-src-include-42ve6t
Open

feat: Let cpp_register() find the types header in src/include/#9
krlmlr wants to merge 1 commit into
f-types-src-includefrom
claude/f-types-src-include-42ve6t

Conversation

@krlmlr

@krlmlr krlmlr commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Patch f-types-src-include of the stack. New in this round — it is the patch duckdb/duckdb-r#2501 needs.

cpp_register() looked for {package}_types.h(pp) in src/ and in inst/include/ only. A package that keeps its own headers in src/include/ — a common enough layout, and duckdb-r's — therefore had to put that one header in inst/include/ to be found, which installs it and turns a private header into part of the package's public C++ interface. duckdb-r calls its copy a vendoring accident for exactly that reason.

src/include/ joins the search, between the two existing locations so the relative precedence of src/ over inst/include/ is unchanged.

Emitting the include

A header found in src/include/ is included as #include "include/foo_types.hpp", not by basename. The generated file is src/cpp11.cpp, and a quoted include resolves relative to the including file's own directory first, so this works with no -I flag — a package need not have arranged for src/include/ to be on the include path. Headers found in the other two locations are still included by basename, so their output is byte-identical to before.

Verification

Two tests added beside the four existing pkg_types cases, one per extension. Full test-register.R passes, as does the rest of the R suite.

Worth sending upstream on its own: nothing about it is specific to this fork, and if r-lib/cpp11 takes it the stack carries one patch less.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K8MneV8KqHYUuC8fWV3X5Q


Generated by Claude Code

`cpp_register()` looked for `{package}_types.h(pp)` in `src/` and in
`inst/include/` only, so a package whose generated `src/cpp11.cpp` must
include that header had to install it -- turning a private header into
part of the package's public interface.

Add `src/include/` to the search, and include the header by its path
relative to `src/` so no extra include flag is needed.

See duckdb/duckdb-r#2501
@krlmlr
krlmlr changed the base branch from main to f-types-src-include August 17, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant