algorithmic modeling for Rhino
Declaring variables which you do not use is either indicative of superfluous code or wrong code. The compiler assumes that any code that is written is meant to be used at least in some circumstance, no matter how rare. Any code that cannot possibly make a difference is thus reason enough for a warning.
You can disable warnings, although I recommend you fix them. You'll notice each warning is associated with a specific number, you can #pragma out specific numbers, like so:
#pragma warning disable 0168
int p;
now you will no longer get an unused-variable warning until you restore the warning with a #pragma restore warning statement.
I see, thanks for the tip! Any chance of setting that globally for all components?
I'd rather not add features that promote bad practice.
Haha, ok...I guess it's a matter of philosophy then. It's really a minor problem anyway, but often I find that I'll think of an algorithm, figure out which variables I'll need and write them down first. Then while scripting, I'll gradually integrate them. Is that bad practise? For some weird reason it satisfies me to see the component turn light grey after I hit play, that's all :)
Oh obviously while writing code I'm breaking all sorts of rules; unused variables, unreachable conditional blocks, premature return statements, ... But eventually I do aim to get rid of all warnings.
If you really, really want to get rid of this though, you can add your warning number to the grasshopper_ignorewarnings.xml file (%appdata%\grasshopper\ folder) while Grasshopper is not running and it will get ignored by the components.
<Fragment name="Settings">
<items count="1">
<item name="CS1702" type_name="gh_string" type_code="10">{A1DD0535-FD3A-42E2-97A0-1ABA7E79F2A4}</item>
<item name="CS0168" type_name="gh_string" type_code="10">{A1DD0535-FD3A-42E2-97A0-1ABA7E79F2A4}</item>
</items>
</Fragment>
Interesting...thanks.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by