fix(cpp): escape cpp keywords#1420
Merged
alexcrichton merged 1 commit intobytecodealliance:mainfrom Nov 19, 2025
Merged
Conversation
1450ef8 to
e6f0f3a
Compare
- remove keywords.wit from expected failures - use std::optional for ResultLift to avoid default constructor issues std::expected doesn't have a default constructor when the value type lacks one. Use std::optional wrapper to defer construction until the result is known. Fixes bytecodealliance#1419 Signed-off-by: Bailey Hayes <[email protected]>
Contributor
Author
|
A bit of an adventure but I am now able to successfully run a wasi:http server. Check it out here: https://github.com/ricochet/sample-wasi-http-cpp |
ricochet
commented
Nov 18, 2025
| "ret" => "ret_".into(), | ||
| "err" => "err_".into(), | ||
| // C standard library macros that conflict when used as identifiers | ||
| "stdin" => "stdin_".into(), |
Contributor
Author
There was a problem hiding this comment.
heads up this is for c as well as C++. Extra care that this is correct should be taken here.
ricochet
commented
Nov 18, 2025
|
|
||
| let tmp = self.tmp(); | ||
| let resultname = self.tempname("result", tmp); | ||
| // Use std::optional to avoid default constructor issues with std::expected |
Contributor
Author
There was a problem hiding this comment.
I believe this is the best approach given the available options, but it was a technique new to me.
This is what this generates:
https://github.com/ricochet/sample-wasi-http-cpp/blob/main/bindings/http_server.cpp#L1268-L1278
Merged
Merged
via the queue into
bytecodealliance:main
with commit Nov 19, 2025
f11a006
21 of 22 checks passed
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.
Fixes #1419
Signed-off-by: Bailey Hayes [email protected]