CCodeGenerator`
CCodeGenerator`

CCodeGenerate

CCodeGenerate[cfun,name,opts]

generates C code from the compiled function cfun using the name as the exported function name, and saves in the file name.c.

CCodeGenerate[cfun,name,filename]

generates output in filename.

CCodeGenerate[{cfun1,cfun2,},{ name1,name2,},filename]

generates C code from several compiled functions and saves in filename.

Details and Options

  • To use CCodeGenerate, you first need to load it using Needs["CCodeGenerator`"].
  • CCodeGenerate can make standalone code or a Wolfram Library.
  • The Wolfram Language contains the necessary headers and libraries for standalone code.
  • You can generate a header for the generated code by setting "CodeTarget" to "WolframRTLHeader".
  • The following option can be given:
  • "CodeTarget""WolframRTL"the type of code to generate

Examples

open allclose all

Basic Examples  (1)

First, load the package:

Generate C code into a file:

Display the file of C code:

Generate code from two compiled functions:

Display the file of C code:

Options  (1)

CodeTarget  (1)

First, load the package:

By default, standalone C code is generated:

This generates the header file for the export:

Wolfram Research (2010), CCodeGenerate, Wolfram Language function, https://reference.wolfram.com/language/CCodeGenerator/ref/CCodeGenerate.html.

Text

Wolfram Research (2010), CCodeGenerate, Wolfram Language function, https://reference.wolfram.com/language/CCodeGenerator/ref/CCodeGenerate.html.

CMS

Wolfram Language. 2010. "CCodeGenerate." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/CCodeGenerator/ref/CCodeGenerate.html.

APA

Wolfram Language. (2010). CCodeGenerate. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/CCodeGenerator/ref/CCodeGenerate.html

BibTeX

@misc{reference.wolfram_2024_ccodegenerate, author="Wolfram Research", title="{CCodeGenerate}", year="2010", howpublished="\url{https://reference.wolfram.com/language/CCodeGenerator/ref/CCodeGenerate.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_ccodegenerate, organization={Wolfram Research}, title={CCodeGenerate}, year={2010}, url={https://reference.wolfram.com/language/CCodeGenerator/ref/CCodeGenerate.html}, note=[Accessed: 21-November-2024 ]}