Like-C
English | 日本語
Compile and run C and C++ in VSCode for Web with a browser-based toolchain. Run the current file from the editor or use the Wash terminal. Local C/C++ toolchain installation is unnecessary.
Getting started
Install Like-C to run programs from the editor. To use the likec command and compiler aliases in a Wash terminal, also install Wash.
- Open a workspace and a C or C++ file, such as sample/scanf.c or sample/stdin.cpp.
- Select ▶ Like-C: Run C/C++ File in the editor toolbar, or run Wash: Open Terminal and type
likec sample/scanf.c.
- When
Number: appears, type an integer and press Enter. The program prints the value and returns its exit code.
The editor runs the current buffer, including unsaved edits to an existing workspace file. Select ■ Like-C: Stop C/C++ Run to stop it. In an interactive terminal, Ctrl+C stops execution and Ctrl+D signals end of input.
Wash commands
| Command |
Behavior |
likec main.c hello |
Compile and run a C or C++ source file, passing hello as a program argument. |
echo 50 \| likec main.c |
Pass input from a pipe. File redirection also works. |
likec --interactive main.c |
Open a separate Like-C terminal for interactive input. |
likec build src/main.c src/helper.cpp -I include -o app.wasm |
Compile and link multiple sources into a WASI executable. Choose a new output filename for each saved build. |
likec run main.wasm |
Run a saved WASI executable without compiling again. |
likec cc main.c helper.c -o app.wasm |
Compile and link in one step, like gcc. An existing output file is replaced. Without -o, the output is a.out.wasm. Sources and objects can be mixed. |
likec cc -c main.c -Iinclude -o main.o |
Compile one source file into a WASM object without running it. |
likec cc main.o helper.o -o app.wasm |
Link WASM objects. Add --driver=c++ to link against the C++ standard library. |
A direct likec main.c command can read from the same Wash terminal. If a pipe or redirection supplies standard input, the program reads from that source.
The sample Makefile shows the compiler commands for a two-source C build. Run its recipes from the Wash terminal to try them. To repeat the build with the same output names, run the cleanup recipe first.
Wash offers gcc and cc as aliases for likec cc, and g++ as an alias for likec cc --driver=c++, when the alias registration API is available and the name is free. Run unalias gcc to remove it from the current terminal, or set likec.gccAlias to false for new terminals. likec cc accepts -std=, -O0 to -O3, -Os, -Oz, -Wall, -Wextra, -Wpedantic, -Werror, -g, and -lm. These override the settings below for that command.
Settings
Search for Like-C in VS Code Settings or use .vscode/settings.json. In a multi-root workspace, settings are resolved for the folder containing the source file.
| Setting |
Default |
Description |
likec.cStandard |
gnu17 |
C language standard, with ISO and GNU modes. |
likec.cppStandard |
gnu++23 |
C++ language standard, with ISO and GNU modes. |
likec.optimization |
"0" |
Optimization level. Use "1", "2", or "3" for speed, or "s" or "z" for size. |
likec.warnings |
default |
Warning level. Options are default, all, extra, and pedantic. |
likec.warningsAsErrors |
false |
Treat compiler warnings as errors. |
likec.debugInfo |
false |
Include debug information in the WASM output. |
likec.runTerminal |
shared |
shared reuses one Like-C terminal and opens another only while every Like-C terminal is running a program. perFile uses a terminal for each file or project. |
likec.clearPreviousOutput |
true |
Clear the previous output when the run button reuses a terminal. |
likec.preserveFocus |
false |
Keep focus in the editor after ▶. The default moves focus to the terminal so you can type input right away. |
likec.timeLimit |
0 |
Stop a program after this many seconds. Time spent waiting for input is not counted. 0 means no limit. |
Configure Run C/C++ File for a workspace folder by adding this to its .vscode/settings.json:
{
"likec.project": {
"sources": ["src/main.c", "src/helper.cpp"],
"includeDirectories": ["include"],
"args": ["hello"]
}
}
The editor run uses unsaved edits to project sources and headers. Wash builds use saved files. Compiler diagnostics appear in the terminal and in Problems when they point to a workspace file. With no project configuration, the editor runs the active file. Running a single file (▶ or likec main.c) also makes header files (.h, .hpp, and similar) in the same folder and its subfolders available to #include.
Limitations
- Interactive input requires WebAssembly JavaScript Promise Integration (JSPI). Piped or redirected input works without it.
- The current WASI toolchain builds C++ without exception support.
- The compiler assets total about 104 MB before compression and are loaded on the first compilation.
Development
Run from the Like-C repository root:
git submodule update --init
npm --prefix vscode-wash ci
npm --prefix vscode-wash run build
npm ci
npm run web
Use npm run typecheck and npm run test:web to check the extension. See requirements, design, and release tasks.
Bug reports and feature requests
Open an issue with the browser version, the command or editor action you used, and a minimal C or C++ example. Like-C issues
License
MIT. Compiler and runtime assets are covered by their respective upstream licenses.
Third-party license review