{"id":25047,"library":"c-next","title":"C-Next","description":"C-Next is a transpiler (v0.2.16) that compiles a safer C dialect to standard C99 for embedded systems. It aims to follow TypeScript's adoption model: incremental, no new runtime, and readable output for existing toolchains (GCC, Clang, IAR). Key features include type-safe register bindings, automatic bit-indexing, and MISRA-friendly preprocessor compatibility. Unlike Rust or other memory-safe languages, C-Next preserves full use of existing C debuggers, profilers, and optimization passes. Release cadence is frequent (minor updates weekly). Current status: working transpiler verified on Teensy and STM32 hardware.","status":"active","version":"0.2.16","language":"javascript","source_language":"en","source_url":"https://github.com/jlaustill/c-next","tags":["javascript","c","embedded","transpiler","safety","misra"],"install":[{"cmd":"npm install c-next","lang":"bash","label":"npm"},{"cmd":"yarn add c-next","lang":"bash","label":"yarn"},{"cmd":"pnpm add c-next","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"C-Next is a CLI tool. No JS import; use via CLI or npx. Install globally: npm i -g c-next.","symbol":"c-next","correct":"npx c-next generate file.cnx"},{"note":"Register fields must use typed syntax (e.g., u32 rw) and offsets. C-style structs are not valid.","wrong":"register MY_REG @ 0x4000 { int field; }","symbol":"register","correct":"register MY_REG @ 0x4000 { FIELD: u32 rw @ 0x00 }"},{"note":"Use `scope` instead of `namespace`. v0.2.x only supports `scope` for encapsulation.","wrong":"namespace MyScope { ... }","symbol":"scope","correct":"scope MyScope { void func() { ... } }"}],"quickstart":{"code":"// Install globally or use npx\nnpm install -g c-next\n\n# Create a file: blink.cnx\n# Register binding with type-safe access\nregister GPIO7 @ 0x42004000 {\n  DR:         u32 rw @ 0x00,\n  DR_SET:     u32 wo @ 0x84,\n  DR_TOGGLE:  u32 wo @ 0x8C,\n}\n\nu32 LED_BIT <- 3;\n\nscope LED {\n  void toggle() {\n    // Type-aware bit indexing on write-only register\n    GPIO7.DR_TOGGLE[LED_BIT] <- true;\n  }\n}\n\n# Transpile to C\nc-next generate blink.cnx\n# Output: blink.h, blink.c","lang":"typescript","description":"Creates a register binding and a toggle function, then transpiles to C99."},"warnings":[{"fix":"Update register definitions to include type and access qualifiers: `register NAME @ addr { FIELD: u32 rw @ offset }`.","message":"In v0.2.x, `register` syntax changed: fields now require bit-width and access qualifiers (e.g., `u32 rw`). Old style without types not supported.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Replace `namespace` with `scope` in all .cnx files.","message":"`scope` replaces `namespace`; `namespace` is no longer valid as of v0.2.0.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Replace `=` with `<-` for variable definitions like `u32 LED_BIT <- 3;`.","message":"Variable assignment syntax changed: use `<-` instead of `=` for binding constants.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Update Node.js to >=18.20.0, or use npx which will use the system's default Node version.","message":"C-Next requires Node.js >=18.20.0. Using older Node versions will fail at runtime.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Include <stdint.h> or equivalent in your project; C-Next output relies on uint32_t and similar types.","message":"The generated C code uses `volatile uint32_t*` for registers. Ensure your toolchain supports C99 stdint.h.","severity":"gotcha","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Update Node.js to 18.20.0 or later, or use a version manager like nvm.","cause":"Running c-next on Node.js < 18.20.0","error":"Error: Node.js version 16.x is not supported. Please use >=18.20.0"},{"fix":"Replace `namespace` with `scope` in the .cnx source file.","cause":"Using deprecated `namespace` keyword instead of `scope`.","error":"SyntaxError: Unexpected token 'namespace'"},{"fix":"Ensure register fields have valid types (e.g., u32, u16) and access (rw, wo, ro). Example: `DR: u32 rw @ 0x00`.","cause":"Register definition missing access qualifiers or using wrong syntax.","error":"TypeError: Cannot read properties of undefined (reading 'fields')"},{"fix":"Use `<-` instead of `=` for variable bindings: `u32 LED_BIT <- 3;`","cause":"Using `=` for variable assignment in C-Next source.","error":"error: expected identifier or '(' before '=' token"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}