Registry / web-framework / maiacpp

maiacpp

JSON →
library1.3.3jsnpmunverified

MaiaCpp (WebCpp) is a C++98 to C transpiler that translates a restricted subset of C++98 to C code, which can then be further compiled to WebAssembly via the MaiaC toolchain. Current stable version is 1.3.3. The project includes a CLI wrapper (webcpp.sh) and supports generating AST (XML, JSON, tree), C output, JS wrapper, WAT, and WASM. It integrates with MaiaC for WebAssembly generation and provides Node.js and browser runners. Differentiators: focuses on a minimal C++98 subset suitable for embedded or WebAssembly use cases, with a migration guide from legacy runner scripts to a dist-oriented flow.

npm install maiacpp
INSTALL
IMPORT
SIG · MAIACPP
M
maiacpp
web-frameworkjavascriptv1.3.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Basic usage of maiaCpp: transpile a C++98 file to C, then generate WASM, and create a distributable package.

#!/bin/bash # Transpile a C++98 file to C and then to WASM using the wrapper # Ensure you have Node.js >=18 and the repo cloned cd /path/to/maiacpp # Simple transpilation: C++ -> C node compiler/cpp-compiler.js --file compiler/examples/test.cpp --c-out out/test.c # Full pipeline: C++ -> C -> WAT -> WASM via webcpp.sh ./bin/webcpp.sh --file compiler/examples/test.cpp --all --out-dir ./out # Generate distribution package (browser + Node runner) ./bin/webcpp.sh --file compiler/examples/test.cpp --dist --out-dir ./dist --name testapp # Run Node dist immediately ./bin/webcpp.sh --file compiler/examples/test.cpp --dist-run --out-dir ./dist --name testapp
webcpp --version
Debug
Known issues
breakingMigration from legacy run-* scripts requires '--mode legacy' flag. New dist-oriented flow uses --mode dist.
fix
Update your scripts: add '--mode legacy' to maintain old behavior, or migrate to dist mode.
affects: >=1.0
deprecatedLegacy wrapper scripts (run-test-node.sh, run-wasm-browser.sh) are deprecated in favor of the unified run-test-cpp.sh and webcpp.sh.
fix
Use run-test-cpp.sh --target all or webcpp.sh for new workflows.
affects: >=1.3
gotchaThe C++98 subset is limited; not all C++98 features are supported. Check test_cpp98_extended.cpp for coverage.
fix
Refer to test files and documentation for supported features. Avoid using unsupported constructs.
affects: *
gotchaThe cpp-compiler.js only outputs C code; further steps (WAT/WASM) require MaiaC (webc) installed separately.
fix
Ensure MaiaC is available in the environment when generating WAT or WASM.
affects: *
gotchaDefault path is C++ -> C (MaiaCpp) -> WAT/WASM (MaiaC). Using --js-out requires MaiaC's webc.
fix
If JS output is needed, ensure the MaiaC toolchain is properly installed and webcpp.sh forwards the --js-out flag.
affects: *
Errors
Common errors & fixes
Error: Could not find MaiaC binary. Please install MaiaC first.
MaiaC is not installed or not in PATH.
fix
Install MaiaC from its repository (https://github.com/souzamonteiro/maiac) and ensure webc is accessible.
SyntaxError: Unexpected token (expected ;) at line X col Y
C++98 code uses constructs not supported by the transpiler.
fix
Simplify code to C++98 subset; avoid templates, exceptions (except try/catch limited), RTTI, etc.
Error: output directory does not exist: ./out
The output directory must exist or --out-dir must be specified.
fix
Create the directory or use --out-dir to specify an existing path.
Error: --file option required when not using default test.cpp
The wrapper expects a file input via --file flag.
fix
Use --file <path> to specify the input C++ file.
Upgrade
Version history
1.3.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
maiacpp — npm install maiacpp · libregistry