In Blockly, you can define a custom block, along with the C code that implements it. Some blocks can take parameters. Such parameters are pasted into the C code macro-style, with the user's data substituting textually for the virtual parameters, @1, @2, ..., etc. If a user leaves out a parameter, an empty string is substituted. This usually results in a compile error, due to a missing parameter, e.g. a + @1, resulting in a +.
My objective is to default to a zero value when such an event occurs, thus preventing a compile error. My brilliant idea was to prepend a zero to the virtual parameter in the C code: a + 0@1, which worked great until the parameter included a 9 digit. Then I realized I was constructing an octal constant. D'oh!
What complicates things even more is if the user plugs in a variable name instead of a constant. 0var_name just won't cut it.
So my question is this: is there some way in C to guarantee a proper result when a user provides a constant, variable, or expression to be substituted for the virtual parameter, and a zero value if it's left empty?