C (.c)

  • Export generates code compatible with the C99 standard.
  • Background

      C programming language.
      General-purpose implementation language for computer systems and applications.
      Developed at Bell Telephone Laboratories in 1972.

    Import 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 "file" 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 "fn" 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 expri as specifying the corresponding elemi.
    • 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.

    Options

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

    Examples

    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]=

    See Also

    Compile  CompiledFunction  StateSpaceModel

    Tutorials

    Introduced in 2010
    (8.0)