Eclipse autoformatting flows c++ lines together when srand() function is used

146 views Asked by At

Getting an odd behavior when auto-formatting when the srand() function is in use.

void randomize() {
    srand (time(NULL));
    for (int i=0; i<10; i++) ;
}

becomes this when formatted with Ctrl-Shift-F:

void randomize() {
    srand (time(NULL));for (int i=0; i<10; i++);
}

In this case, the entire line is moved. Other cases, just the first token gets moved. Here is another resulting example from x++; as the follow-on line:

srand(time(NULL));x
++;

Is there any trick to disable or correct this for srand()?

I am using Rational Developer for System Z, Version 9.0. What plug-in does this? RDz checks for updates each time I start but perhaps that is not working.

1

There are 1 answers

0
seth10 On

I had the same problem, adding a second semicolon at the end of the line fixed it for me. I'm not sure why, but if anyone has found out I'm sure we would all love to know.

    srand (time(NULL));

uint8_t data[8];
    …

    srand (time(NULL));;
    uint8_t data[8];
    …