Registry / devops / c-next

c-next

JSON →
library0.2.16jsnpmunverified

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.

npm install c-next
INSTALL
IMPORT
SIG · C-NEXT
C
c-next
devopsjavascriptv0.2.16
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

c-next
npx c-next generate file.cnx
C-Next is a CLI tool. No JS import; use via CLI or npx. Install globally: npm i -g c-next.
register
register MY_REG @ 0x4000 { FIELD: u32 rw @ 0x00 }
register MY_REG @ 0x4000 { int field; }
Register fields must use typed syntax (e.g., u32 rw) and offsets. C-style structs are not valid.
scope
scope MyScope { void func() { ... } }
namespace MyScope { ... }
Use `scope` instead of `namespace`. v0.2.x only supports `scope` for encapsulation.

Creates a register binding and a toggle function, then transpiles to C99.

// Install globally or use npx npm install -g c-next # Create a file: blink.cnx # Register binding with type-safe access register GPIO7 @ 0x42004000 { DR: u32 rw @ 0x00, DR_SET: u32 wo @ 0x84, DR_TOGGLE: u32 wo @ 0x8C, } u32 LED_BIT <- 3; scope LED { void toggle() { // Type-aware bit indexing on write-only register GPIO7.DR_TOGGLE[LED_BIT] <- true; } } # Transpile to C c-next generate blink.cnx # Output: blink.h, blink.c
cnext --version
Debug
Known issues
breakingIn v0.2.x, `register` syntax changed: fields now require bit-width and access qualifiers (e.g., `u32 rw`). Old style without types not supported.
fix
Update register definitions to include type and access qualifiers: `register NAME @ addr { FIELD: u32 rw @ offset }`.
affects: >=0.2.0
breaking`scope` replaces `namespace`; `namespace` is no longer valid as of v0.2.0.
fix
Replace `namespace` with `scope` in all .cnx files.
affects: >=0.2.0
breakingVariable assignment syntax changed: use `<-` instead of `=` for binding constants.
fix
Replace `=` with `<-` for variable definitions like `u32 LED_BIT <- 3;`.
affects: >=0.2.0
gotchaC-Next requires Node.js >=18.20.0. Using older Node versions will fail at runtime.
fix
Update Node.js to >=18.20.0, or use npx which will use the system's default Node version.
affects: >=0.2.0
gotchaThe generated C code uses `volatile uint32_t*` for registers. Ensure your toolchain supports C99 stdint.h.
fix
Include <stdint.h> or equivalent in your project; C-Next output relies on uint32_t and similar types.
affects: >=0.2.0
Errors
Common errors & fixes
Error: Node.js version 16.x is not supported. Please use >=18.20.0
Running c-next on Node.js < 18.20.0
fix
Update Node.js to 18.20.0 or later, or use a version manager like nvm.
SyntaxError: Unexpected token 'namespace'
Using deprecated `namespace` keyword instead of `scope`.
fix
Replace `namespace` with `scope` in the .cnx source file.
TypeError: Cannot read properties of undefined (reading 'fields')
Register definition missing access qualifiers or using wrong syntax.
fix
Ensure register fields have valid types (e.g., u32, u16) and access (rw, wo, ro). Example: `DR: u32 rw @ 0x00`.
error: expected identifier or '(' before '=' token
Using `=` for variable assignment in C-Next source.
fix
Use `<-` instead of `=` for variable bindings: `u32 LED_BIT <- 3;`
Upgrade
Version history
0.2.16latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
Resources
c-next — npm install c-next · libregistry