Skip to content

Revise and expand on C/C++ language support section #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

catamorphism
Copy link
Contributor

I tried to define some undefined terms, and verified the commands and their output.

I tried to define some undefined terms, and verified the commands and their output.
Copy link
Collaborator

@vados-cosmonic vados-cosmonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update and run through the C docs @catamorphism !

@@ -0,0 +1,6 @@
#include "adder.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've quite intentionally avoided putting other tutorial examples inside this codebase, but I'm thinking we should reconsider that. I'd personally like to see all code we put in the language guides hosted in component-docs so we can at least test them via CI.

That said, this has come up and we decided against it -- maybe I'm misremembering.

Thoughts @itowlson , @kate-goldenring ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that was my thought -- that if the code examples were in separate files, they could eventually be tested in CI.

uint32_t exports_docs_adder_add_add(uint32_t x, uint32_t y)
{
uint32_t result = x + y;
printf("%d", result);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
printf("%d", result);

We can probably get rid of the stdio.h requirement which allows for more minimal components. adder should technically not need wasi:cli

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the point of including the example that uses printf was to show what happens if you use WASI interfaces and don't include the --adapt flag?

Copy link
Collaborator

@vados-cosmonic vados-cosmonic Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh thank you sorry I lost this context. This would be fine as-is, but what do you think about adding a comment here? Above the printf that explains a little more (and at a glance anyone who sees this file will understand the point of the example).

I'm thinking of a note like:

// On traditional platforms, printf() prints to stdout, but on Wasm platforms
// stdout and the idea of printing to output stream is introduced and managed by
// WASI. 
//
// When building this code with wasi-libc (as a part of wasi-sdk), the printf call
// below is replaced with code that uses `wasi:cli/stdout` and `wasi:io/streams`.

catamorphism and others added 27 commits August 6, 2025 12:46
Copy link
Collaborator

@vados-cosmonic vados-cosmonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Thanks for making these changes @catamorphism -- at this point I think once we have some input from others on the including-example-code-in-the-repo issue and the other stuff resolved we should merge this in.

If we haven't seen movement/discussion on the other stuff by monday, let's move this forward and merge.

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.

2 participants