# 将程序编译为WebAssembly

您可以先使用clang进行编译，然后使用wasm-ld进行链接，以将C程序编译为作为WebAssembly模块运行。 根据所使用的操作系统和Clang版本，您可能会使用其他版本的WebAssembly链接器，例如macOS上的wasm-ld或Debian上的wasm-ld-8。‌

在macOS上编译为WebAssembly：‌

1.通过运行以下clang命令来编译程序：‌

**`clang --target=wasm32 -c -O3 reverse.c`**&#x200C;

2.通过运行以下wasm-ld命令，运行链接器以创建WebAssembly模块：‌

**`wasm-ld --no-entry --export-dynamic --allow-undefined reverse.o -o reverse.wasm`**<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mixdao.gitbook.io/dfinity/san-shou-ba-shou/4.-shi-yong-bu-tong-yu-yan-kai-fa/shi-yong-c/untitled-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
