What to put in empty if statement?

Tyrus
Tyrus Member Posts: 6 Member

The short story is I need to allow an if statement to be empty. Since SublimeKSP gives me an error when an if statement is empty, I need to put something in there to satisfy it. I could declare a dummy variable and write to it, but I don't want to declare anything extraneous like that. What is a good fast, low memory instruction I can put in my empty if statement?

Best Answer

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    Answer ✓

    You can always do an i = i thing as a sort of a no-op. But with this sKSP option disabled you don't have to do anything, just leave the branch empty.

Answers

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod

    There's an option in SublimeKSP not to warn on empty if/case statements.


  • Tyrus
    Tyrus Member Posts: 6 Member

    Very cool, I did not know about that. Thanks

    SublimeKSP's warning says that an empty if statement is equivalent to invoking the "exit" function. I haven't used the exit function personally yet, but the manual says it exits functions or callbacks. There's a good chance that I don't want to do that either. If that is the case, then do I have any other recourse than to put a filler statement in my otherwise empty if statement?

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    Answer ✓

    You can always do an i = i thing as a sort of a no-op. But with this sKSP option disabled you don't have to do anything, just leave the branch empty.

Back To Top