QUICK REFERENCE

Conversion checklist

Use this sequence to prepare Python, convert it, and verify the generated C in your own build environment.

Prepare the Python

  1. Start with functions whose expected results you know.
  2. Choose a mode using Supported conversions, and follow its examples.
  3. For typed conversion, annotate parameters/results and keep variable types consistent. Supply all imported source modules.
  4. For runtime conversion, use explicitly supplied modules and the admitted string, container, class, function, and comprehension forms. Use annotations where a checked type boundary is useful.
  5. Assign every local and field before reading it. Include cases where branches or loops do not execute.

Convert and inspect

  1. Select Typed or Runtime in the Transpile menu, then click the Transpile button.
  2. Read diagnostics and correct rejected source forms. Review warnings on successful output.
  3. Convert again after edits. Save C only when it matches the intended source and settings.
  4. Review the generated function declarations and the selected mode's C caller requirements.

Build with a C11 toolchain

Use the Compile C dialog to select PCFC11, GCC/MinGW-w64, Clang, MSVC or Clang-cl. The commands below show the equivalent external GCC workflow.

PyCForge emits source. Use a C application or test harness to call the generated functions. To compile a typed output to an object file with GCC:

gcc -std=c11 -Wall -Wextra -c output.c -o output.o

For runtime output with a Python main() callable without arguments, enable its optional entry wrapper:

gcc -std=c11 -DPYCF_RUNTIME_MAIN output.c -o program -lm

Follow typed string ownership and file status handling for typed output, or context lifetime and runtime errors for runtime output. Review compiler messages before running the program.

Complete typed C caller

Convert the add example to example.c. Save the following as caller.c in the same directory. Including the generated C makes its exact declarations available to this small standalone caller.

#include <inttypes.h>
#include <stdio.h>
#include "example.c"

int main(void)
{
    printf("%" PRId64 "\n", add(2, 3));
    return 0;
}

With a compatible GCC toolchain, build only the caller; do not also pass example.c, because it is already included:

gcc -std=c11 -Wall -Wextra caller.c -o caller

Run ./caller on Linux/macOS, or .\caller.exe in Windows PowerShell. It prints 5. For a larger C project, use matching declarations in a header and compile generated C as a separate translation unit.

Compare results with Python

Retain a reproducible example

Keep the Python source, selected mode, settings, package version, generated C, test inputs, and expected results together. For a problem report, reduce the source to the smallest example that reproduces it and include the exact diagnostic or compiler message.