Skip to content
Andrew Johnson edited this page Feb 24, 2025 · 7 revisions

LM now accepts C code to compile.

Principle of Unchanged

The C Frontend for LM can optionally emit C code as a target. In this case, the C code should be unchanged from the original source file.

LM does not handle preprocessing, so C code is only compared to original source after preprocessing has taken place. Whitespace may be added or removed. Source location information may be added (this can be disabled). Nonstandard behavior may cause changes to the output code.

Aside from these exceptions, the output C files should be byte identical to the original input. If you see an exception to this rule, please file a bug report.

Nonstandard Behavior

We try to conform to ANSI C standards but there are some places where interoperability with other LM code yields some non-standard behavior.

  • C Code that compiles with a major C compiler should compile with LM
  • C Code can call out to other LM functions
  • C Code that calls LM functions can potentially use "punned" symbols which need to be mangled