Clang-format breaks #define and #include directive


I hope this is the right place to ask this.
Recently I started using clang-format. And it works really really great!

I just find odd that code like the following:

#include "header.h"
#define aNumber 10

gets converted into

#include \
#define aNumber \

I tried llvm and google styles + other various flags and everything
lead me to the same behaviour regarding #defines/#includes.
How can I disable the break on #defines and very simple #defines?
I saw some sources in llvm and no #include or #define look like above.
Is this a bug? Maybe I am just missing something :slight_smile:

Any help is greatly appreciated.



I have never seen this particular behavior. What version are you running? Are you possibly using some exotic file encoding? In LLVM and Google style, clang-format most definitely should not be doing this.


I remember to have seen such a bug maybe half a year ago. Ignacio, are you using the latest version of clang-format from the svn repositorz?


Sorry for the late response,

I realized I do have some exotic characters in my files, but I think the reason I got #include and #define lines broken was due to an incorrect .clang-format file.

My .clang-format file was created like:

$ ./clang-format -dump-config -style=google > .clang-format

which I believe was the reason (?), it has "------" at the first line and "..." and the end. I don't remember changing anything else in particular but things are working as expected now.


Nov 6, 2013 3:58 AM、Tobias Grosser <> のメール: