On Mon, May 18, 2020 at 8:08 PM Gregory Nutt <spudan...@gmail.com> wrote:
> > > Actually, I just ran into another nxstyle-related conundrum and I > > don't see anything about this in the coding standard. > > > > Regarding indentations, the coding standard says that everything is > > indented by units of 2, so that all C code begins at column 4n + 2. > > But preprocessor statements begin with a '#' in column 1 so although > > indentation remains the same, it shifts by 1 character. > > > > Now, the code in arch/arm/src/stm32/stm32_allocateheap.c beginning > > around like 100 throws bad alignment errors: > > > > [[[ > > > > #elif defined(CONFIG_STM32_STM32F10XX) > > > > /* Set the end of system SRAM */ > > > > # define SRAM1_END CONFIG_RAM_END > > > > /* Check if external FSMC SRAM is provided */ > > > > # ifdef CONFIG_STM32_EXTERNAL_RAM > > > > ]]] > > > > That code consists of #define / #undef statements conditioned upon > > various #if defined(), with comment blocks in between. These are > > aligned to match up with the preprocessor statements but because of > > the '#' shift they are indented by 3 or 5 spaces: > > > > $ tools/nxstyle arch/arm/src/stm32/stm32_allocateheap.c > > arch/arm/src/stm32/stm32_allocateheap.c:110:3: error: Bad comment > alignment > > . > > . > > . > > > > How should this be handled? > > Are you sure it is not complaining about the comments. The comments at > lines 110, 116, and 116 begin in column 3. That should generate a > complaint. In my version of code line 110 is not a pre-processor > directive but the truly, improperly aligned comment. You're right, it is complaining about the comments being indented by an odd number. So, would the correct indentation for the comment be at 2 columns or at 4 columns here? Either way, the left edge of the comment will not line up with the "define" or "undef." Nathan