The documentation of SymbolicC, more specifically of COperator, states that Parentheses are added as necessary together with the following example:
In[1]:= Needs["SymbolicC`"]
In[2]:= COperator[Times, {COperator[Plus, {a, b}], c}] // ToCCodeString
Out[2]= "(a + b) * c"
I expected the same result, when I used CExpression to create the a+b-part of the expression:
In[3]:= COperator[Times, {CExpression[a + b], c}] // ToCCodeString
Out[3]= "a + b * c"
However, the required parentheses were not added. They may be added explicitly using CParentheses:
In[4]:= COperator[Times, {CParentheses@CExpression[a + b], c}] // ToCCodeString
Out[4]= "(a + b) * c"
This feels wrong to me. I expected all of Out[2], Out[3] and Out[4] to be the same.
Is this a bug?
COperatordoesn't "see" within the expression generated byCExpression, so it doesn't realized that it needs to be wrapped in parentheses. – MarcoB Oct 16 '15 at 21:50