# SymbolicCCSwitch basically broken?

The CSwitch manual page gives the example

CSwitch["val", 1, CAssign["i", 10], CBreak[], 2, CAssign["i", 3],
CBreak[]] // ToCCodeString


which generates this illegitimate C code:

switch ( val)
{
case 1:
i = 10;

case break;:
2;

case i = 3:
break;
}


And I cannot even get it to produce just the first case, i.e.

switch ( val)
{
case 1:
i = 10;
break;
}


I tried removing the rest from the first example,

CSwitch["val", 1, CAssign["i", 10], CBreak[]] // ToCCodeString


but this gives

ToCCodeString::unk: An unknown element, CSwitch[val,1,CAssign[i,10],CBreak[]], was found when generating code >>

CUnknownElement[CSwitch[val, 1, CAssign[i, 10], CBreak[]]]

and

CSwitch["val", 1, {CAssign["i", 10], CBreak[]}] // ToCCodeString

generates the right code but again gives a message.

Also, the syntax-highlighting for CSwitch should probably tolerate any amount of arguments.

Is there something wrong with my setup or can somebody confirm this?

This is 10.4.

• CSwitch is a little bent, but it's documentation shows serious fractures. – m_goldberg Aug 11 '16 at 2:28
• Was this reported? I still see it in the very latest version. Shouldn't we add the bugs tag? – Gustavo Delfino Jan 24 at 22:15

The documentation for CSwitch looks like it was written by somebody who didn't understand what the SymbolicC package or, for that matter, what a C switch is supposed to do. The following produces something more like C code and makes more sense as Mathematica code.

Needs["SymbolicC"]
CSwitch["val",
1, {CAssign["i", 10], CBreak[]},
2, {CAssign["i", 3], CBreak[]}] // ToCCodeString


Still I would say that the SymbolicC package is very much a work in progress.

• Is it an officially supported package, i.e. would you contact support about this? – masterxilo Aug 11 '16 at 8:07
• @masterxilo. Yes, it is an officially provided package and should be supported by Wolfram Research, Inc. I encourage you to contact WRI tech support concerning what you have found. – m_goldberg Aug 11 '16 at 8:37
• @masterxilo Yes, report it. Similar bugs I reported in this package in the past were fixed. – Szabolcs Sep 3 '17 at 21:27