Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 3-4-1 issues
#1
We're having issues complying with rule 3-4-1 in a number of functions that initialise a temporary variable which is subsequently modified and tested within a loop. I appreciate in many cases this can be resolved with recursion, however, it seems an excessive solution given the additional considerations required.

The only other solution we've found (that doesn't conflict with other rules) is to declare and initialise a struct with the members set to the required values. e.g.
Code:
void f (void)
{
    struct FOO
    {
        int Index;
        int Result;
    } ;
    
    for (FOO Test = {0, 0}; Test.Index < 10; Test.Index++)
    {
        Test.Result += SomeTestFunction( );
    
        if (Test.Result > 5)
        {
            break;
        }
    }
}
What is the an 'expected' implementation of such functionality?
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 5 Guest(s)