Unless I'm doing something wrong I think I've found a bug in Code Warrior, when using Auto Indentation
My indentation options (in Window/Preferences/C/C++/Code Style/Formatter/Edit/Indentation) are:
Take a simple switch statement (I've used a dash to indicate a space below):
uint8_t var;
switch (var)
{
case 1:
--perform_action_1();
--break;
case 2:
--perform_action_2();
--break;
}
I want the case statement to start same at the column as the switch statement (as above). Typing the code above produces correctly indented code. However if I add parenthesis around the case statement expression (i.e. case (1) : instead of case 1:) changes the indentation to:
uint8_t var;
switch (var)
{
case (1):
----perform_action_1();
break;
case (2):
----perform_action_2();
break;
}
I can't see anything in the code style formatter options that should cause adding parenthesis to result in thiis crazy indentation.
So:
As an addendum this same issues is present in Kinetis Design Studio so the problem may be with Eclipse.
Hello Ben.
I am not sure if I fully understand your questions.
from my understanding, you want to set default indentation for wrapped lines. did you try this:
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Jennie,
I want:
case 1: // No Parenthesis
function();
break;
to have the same indentation as:
case (1): // Parenthesis
function();
break;
When in fact adding the parenthesis appears as:
case (1): // Parenthesis
function();
break;
Hello Ben,
I have reproduced your problem.
I will contact development team for it.
If I get any news, I will let you know.
Thanks for bringing the problem to our attention.
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks