{"id":25918,"library":"maiacpp","title":"maiaCpp","description":"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.","status":"active","version":"1.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/souzamonteiro/maiacpp","tags":["javascript","cpp","c++","c++98","transpiler","compiler","wasm","webassembly"],"install":[{"cmd":"npm install maiacpp","lang":"bash","label":"npm"},{"cmd":"yarn add maiacpp","lang":"bash","label":"yarn"},{"cmd":"pnpm add maiacpp","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[],"quickstart":{"code":"#!/bin/bash\n# Transpile a C++98 file to C and then to WASM using the wrapper\n# Ensure you have Node.js >=18 and the repo cloned\ncd /path/to/maiacpp\n\n# Simple transpilation: C++ -> C\nnode compiler/cpp-compiler.js --file compiler/examples/test.cpp --c-out out/test.c\n\n# Full pipeline: C++ -> C -> WAT -> WASM via webcpp.sh\n./bin/webcpp.sh --file compiler/examples/test.cpp --all --out-dir ./out\n\n# Generate distribution package (browser + Node runner)\n./bin/webcpp.sh --file compiler/examples/test.cpp --dist --out-dir ./dist --name testapp\n\n# Run Node dist immediately\n./bin/webcpp.sh --file compiler/examples/test.cpp --dist-run --out-dir ./dist --name testapp\n","lang":"javascript","description":"Basic usage of maiaCpp: transpile a C++98 file to C, then generate WASM, and create a distributable package."},"warnings":[{"fix":"Update your scripts: add '--mode legacy' to maintain old behavior, or migrate to dist mode.","message":"Migration from legacy run-* scripts requires '--mode legacy' flag. New dist-oriented flow uses --mode dist.","severity":"breaking","affected_versions":">=1.0"},{"fix":"Use run-test-cpp.sh --target all or webcpp.sh for new workflows.","message":"Legacy wrapper scripts (run-test-node.sh, run-wasm-browser.sh) are deprecated in favor of the unified run-test-cpp.sh and webcpp.sh.","severity":"deprecated","affected_versions":">=1.3"},{"fix":"Refer to test files and documentation for supported features. Avoid using unsupported constructs.","message":"The C++98 subset is limited; not all C++98 features are supported. Check test_cpp98_extended.cpp for coverage.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure MaiaC is available in the environment when generating WAT or WASM.","message":"The cpp-compiler.js only outputs C code; further steps (WAT/WASM) require MaiaC (webc) installed separately.","severity":"gotcha","affected_versions":"*"},{"fix":"If JS output is needed, ensure the MaiaC toolchain is properly installed and webcpp.sh forwards the --js-out flag.","message":"Default path is C++ -> C (MaiaCpp) -> WAT/WASM (MaiaC). Using --js-out requires MaiaC's webc.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install MaiaC from its repository (https://github.com/souzamonteiro/maiac) and ensure webc is accessible.","cause":"MaiaC is not installed or not in PATH.","error":"Error: Could not find MaiaC binary. Please install MaiaC first."},{"fix":"Simplify code to C++98 subset; avoid templates, exceptions (except try/catch limited), RTTI, etc.","cause":"C++98 code uses constructs not supported by the transpiler.","error":"SyntaxError: Unexpected token (expected ;) at line X col Y"},{"fix":"Create the directory or use --out-dir to specify an existing path.","cause":"The output directory must exist or --out-dir must be specified.","error":"Error: output directory does not exist: ./out"},{"fix":"Use --file <path> to specify the input C++ file.","cause":"The wrapper expects a file input via --file flag.","error":"Error: --file option required when not using default test.cpp"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}