C (.c)

C programming language.
General purpose implementation language for computer systems and applications.
Developed at Bell Telephone Laboratories in 1972.
  • Export generates code compatible with the C99 standard.

Import and ExportImport and Export

  • Export["file.c", {expr1, expr2, ...}] exports a list of compiled functions to one set of code and header files.
  • Export["file.c", ss] exports a discrete-time state-space model ss.
  • Export["file.c", CompiledFunction[...]] exports a CompiledFunction object to C language code and header files.
  • Export["file.c", StateSpaceModel[...]] exports a discrete-time StateSpaceModel object.
  • Export uses the string in Export["file.c", CompiledFunction[...]] as the C function name.
  • The exported source and header files have the same file name base.
  • Export["file.c", "fn"->expr] exports expr using as the C function name.
  • Export["file.c", {"fn1"->expr1, "fn2"->expr2, ...}] exports multiple CompiledFunction objects to one set of code and header files.
  • Export["file.c", expr, elem] creates code and header files by treating expr as specifying element elem.
  • Export["file.c", {expr1, expr2, ...}, {{elem1, elem2, ...}}] treats each as specifying the corresponding .
  • Export["file.c", expr, opt1->val1, ...] exports expr with the specified option elements taken to have the specified values.
  • Export["file.c", {elem1->expr1, elem2->expr2, ...}, "Rules"] uses rules to specify the elements to be exported.
  • See the reference page for full general information on Export.
  • ExportString supports the C language format.

OptionsOptions

  • Export option:
  • "CreateHeaders"Truewhether to generate header file

ExamplesExamplesopen allclose all

Basic Examples (4)Basic Examples (4)

Generate C files for a mathematical function:

In[1]:=
Click for copyable input
Out[1]=

Export multiple CompiledFunction objects to a C source and header files:

In[1]:=
Click for copyable input
Out[1]=

Export a StateSpaceModel object to C source and header files:

In[1]:=
Click for copyable input
Out[1]=

Create source and header files with given function names:

In[1]:=
Click for copyable input
Out[1]=
New in 8
New to Mathematica? Find your learning path »
Have a question? Ask support »