8
$\begingroup$

I'm continuing to experiment with the SymbolicC` package, and it's crucial to be able to inspect the generated code in order to do, well, anything useful with it. The ToCCodeString makes this possible, but as far as I can tell, produces code with sensible line breaks but no indentation. Reading unindented code is sort of possible, but not at all fun. Is there an option to turn indentation on?

Right now, I've set things up so I can use the "Artistic Style" package for this purpose, and while it looks like a pretty nice program, relying on it means one more dependency on top of Mathematica and Visual Studio.

UPDATE to add: I'm interested in inspecting code that I generate programmatically, and developing the program to do the generation interactively in a notebook. I'd prefer not to have to take manual steps like using ToCCodeString to generate the string, and then copy'n'paste it to Visual Studio to inspect it unless I really have to.

$\endgroup$
4
  • $\begingroup$ Does this msdn suit your purposes? $\endgroup$
    – rcollyer
    Commented Nov 25, 2013 at 15:12
  • 4
    $\begingroup$ ToCCodeString has the "Indent" option, which defaults to None. Set it to the number of tabs you want for an indentation, and you should be fine. $\endgroup$ Commented Nov 25, 2013 at 15:36
  • $\begingroup$ @LeonidShifrin I can't upvote that and possibly accept it unless you post it as an answer, not a comment. :) $\endgroup$
    – Pillsy
    Commented Nov 25, 2013 at 15:46
  • $\begingroup$ All right, done :) $\endgroup$ Commented Nov 25, 2013 at 16:11

1 Answer 1

11
$\begingroup$

ToCCodeString has the "Indent" option, which defaults to None. Set it to the number of tabs you want for an indentation, and you should be fine.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.