Background
Using STM32CubeMxIDE 1.8 (Eclipse® 2021-03 and CDTTM version 10.2.0). I've adjusted to a custom formatter with Window
>> Preferences
>> C/C
>> CodeStyle
>> Formatter
>> Edit
, and created my own with some Google, GNU, and personal preference. I want something like this for large functions:
foo(0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000);
Issue
Given my poorly formatted code:
#define mainEXAMPLE_32BIT 0x00000000
__myExampleFunctionFoo ( mainEXAMPLE_32BIT, mainEXAMPLE_32BIT,mainEXAMPLE_32BIT, mainEXAMPLE_32BIT,mainEXAMPLE_32BIT);
If I format by save or pressing CTRL SHIFT F and format the entire page it becomes:
__myExampleFunctionFoo(mainEXAMPLE_32BIT, mainEXAMPLE_32BIT,
mainEXAMPLE_32BIT, mainEXAMPLE_32BIT,
mainEXAMPLE_32BIT);
Great! This is what I want.
But it only works once. When I save file or press CTRL SHIFT F a second time and I now have:
__myExampleFunctionFoo(mainEXAMPLE_32BIT, mainEXAMPLE_32BIT,
mainEXAMPLE_32BIT,
mainEXAMPLE_32BIT,
mainEXAMPLE_32BIT);
The second argument moves forward to the same indentation as it's function. This only seems to happen with defines/macros.
I've tried my own, GNU, and other CDT formatters options. I suspect if it's not a bug that it's an issue with expansion of macros or generally some macro option.
Any advice? I suspect the best response I'll get is to install Clang-Format.
CodePudding user response:
I could find nothing on this, no way to see what the built in formatter was doing and why, and did eventually switch to clang-format.
The plug-in for Eclipse is called CppStyle.