#292 C/C++: Wrong indent in a specific use case of MACRO

closed-fixed
Jim Pattee
None
7
2015-01-03
2014-07-02
Dong Nguyen
No

Failed case description:

#ifdef MACRO
if(function1())
{ //open brace
#endif
#ifndef MACRO
//***** noticed line ****/
if(function2())
{ //another open brace
#endif
    // some code
} //close brace
    /*
    The rest of code
    */

after beautify by astyle, all the code from [noticed line] to the end of file is shifted one indent.

#ifdef MACRO
if(function1())
{ //open brace
#endif
#ifndef MACRO
//***** noticed line ****/
    if(function2())
    { //another open brace
#endif
        // some code
    } //close brace
        /*
        The rest of code
        */

Discussion

  • Jim Pattee
    Jim Pattee
    2014-10-30

    • status: open --> open-remind
    • assigned_to: Jim Pattee
    • Priority: 5 --> 7
     
  • Jim Pattee
    Jim Pattee
    2014-10-30

    There is code above and below the code you posted which needs to be considered.
    AStyle cannot format correctly without having all the matching brackets.
    If you think there is a problem post the code from the entire function.

     
  • Jim Pattee
    Jim Pattee
    2014-11-20

    • Status: open-remind --> closed-fixed