cutils.py 383 B

12345678
  1. from sympy.printing.c import C99CodePrinter
  2. def render_as_source_file(content, Printer=C99CodePrinter, settings=None):
  3. """ Renders a C source file (with required #include statements) """
  4. printer = Printer(settings or {})
  5. code_str = printer.doprint(content)
  6. includes = '\n'.join(['#include <%s>' % h for h in printer.headers])
  7. return includes + '\n\n' + code_str