CStruct


is a symbolic representation of a struct.

CStruct[name]
declares a struct without specifying the contents.

CStruct[None, members]
does not give the struct a name.

DetailsDetails

  • SymbolicC expressions are inert; they evaluate to themselves, staying in an unevaluated form.
  • SymbolicC expressions can be converted into a C string with ToCCodeString.
  • The members of the struct can be specified with lists or with CDeclare.

ExamplesExamplesopen allclose all

Basic Examples (1)Basic Examples (1)

To use SymbolicC, you first need to load the package:

In[1]:=
Click for copyable input

This creates a struct:

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

You can use CDeclare to declare the members of the struct:

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

You can drop the name for the struct by using a specification of None:

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

You can drop the contents of the struct to make an incomplete type:

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

You can use an incomplete type with a typedef:

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

You can nest a union inside a struct:

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