Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Symbolic Representation of C Code >

ToCCodeString

ToCCodeString[symbolicC]
generates a string of C code from a symbolic C expression.
  • SymbolicC expressions are inert; they evaluate to themselves, staying in an unevaluated form.
  • SymbolicC expressions can be converted into a C string with .
To use SymbolicC you first need to load the package:
This creates an entire program:
To use SymbolicC you first need to load the package:
In[1]:=
Click for copyable input
This creates an entire program:
In[2]:=
Click for copyable input
Out[2]=
Writing programs that write other programs, also called "metaprogramming" or simply "code generation", is a useful technique in generating specialized and optimized code:
SymbolicC can create domain-specific languages in Mathematica and translate them to C. This example defines a simple language that converts Mathematica points and polygons into calls to the OpenGL API:
Since understands the C operator precedence rules, it can decrease the number of parentheses in the program:
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF