1
votes

Quick question:

I have some code that looks like:

if (interactive)
    ret = main_interactive(ctx, debug, use_aio);
else
    ret = main_server(ctx, debug);

/*
 * In case we got here through an error in the main thread make sure all
 * the worker threads are signaled to shutdown.
 */

when I run it through clang-format 7.0.1-8 (debian) (with this .clang-format file), I get this:

if (interactive)
    ret = main_interactive(ctx, debug, use_aio);
else
    ret = main_server(ctx, debug);

    /*
 * In case we got here through an error in the main thread make sure all
 * the worker threads are signaled to shutdown.
 */

You can see that the first line of the comment block is incorrectly indented.

Any suggestions?

1
I am not able to reproduce your error. If you use a different system and config file, it is unlikely that you will see this problem.Ross Jacobs
I was able to reproduce it on a different system with the same config file. I did not use just the snippet, but the entire file, in case something about the top of the file is confusing clang-format.Robin

1 Answers

0
votes

I've tried you clang-format config in CLion 2020.RC1 and it seems the problem is comment's first line (/*) is indented with tab (which is 8-spaces wide per your config), while the rest of the comment's lines are indented with 4 spaces.
Here is how you code looks like with "show whitespace: on" in CLion:

code with whitespace

This can be fixed with option ReflowComments: true. That way all comment's lines will be indented with tabs.