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. $\endgroup$