Repository navigation
Conversation
Signed-off-by: Ikeh Chukwuka <mrikehchukwuka@gmail.com>
Contributor
Author
|
hi @teor2345 i was thinking of these edits to the docs, since the ## Testing Quirks
-Sometimes the C++ code extracted by `cpp_build` will become outdated, and you will get errors like:
+`cpp-overload-test/build.rs` tells Cargo to rerun `cpp_build` whenever a file in
+`cpp-overload-test/src` changes, so new or changed `cpp!` blocks are picked up on the next build.
+
+If you still get errors like:
```text
error: This cpp! macro is not found in the library's rust-cpp metadata.
NOTE: Only cpp! macros found directly in the program source will be parsed -
NOTE: They cannot be generated by macro expansion.
...
error: cannot find macro `__cpp_closure_impl` in this scope
```
-To fix these errors, run `cargo clean` then rebuild.
-If the errors still happen after a clean, check your Rust and C++ code is compiling correctly.
+check that the `cpp!` block is written directly in `cpp-overload-test/src`, and isn't generated by
+another macro, or used in an example or binary (`cpp_build` only runs for `lib.rs`).
+If the errors still happen, run `cargo clean` then rebuild, and check your Rust and C++ code is
+compiling correctly.what do you think about it? |
Collaborator
Go for it, it is easier for me to review doc changes in the GitHub changes view than as a diff in a comment. |
teor2345
reviewed
Oct 22, 2026
teor2345
left a comment
Collaborator
There was a problem hiding this comment.
This looks good but I'd like to add a CI test if possible.
| // `cc` prints `rerun-if-env-changed` lines, which turns off Cargo's default rescan of the | ||
| // package, so instruct Cargo to rerun this script whenever `src/` changes and pick up | ||
| // `cpp!` updates. | ||
| println!("cargo::rerun-if-changed=src"); |
Collaborator
There was a problem hiding this comment.
Is it possible to add a CI test for this change?
This will make sure:
- the change does what it is documented to do
- it keeps on doing that when we make future changes to the build script, or upgrade cpp or cpp_build
- it works in the CI environment
For example, you could add a CI test script that:
- Builds some cpp! code and checks its output
- Adds a new cpp! Invocation and/or changes the C++ code inside an existing one
- Rebuilds and checks the build is successful and the output has changed
You could create a replacement file (which isn't in the build by default) and use cp to copy it over the original file in step 2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
related to #61
adds
cargo::rerun-if-changed=srctocpp-overload-test/build.rs.once a build script prints any
rerun-ifline, cargo stops rescanning the package (cargo docs). so editing acpp!block never reran the script, and the build failed with "This cpp! macro is not found in the library's rust-cpp metadata" untilbuild.rswas touched.after
touch cpp-overload-test/src/stdcpp/forward_list.rsandcargo build -v:before:
after: