0

Some c code Before format:

#define MS_DEF(type) extern type

MS_DEF(int) my_func(int a, int b, int c, const char *x, const char *y, const char *z)
{
  // do something
  return 0;
}

After format (clang-format --style=LLVM test.c) :

#define MS_DEF(type) extern type

MS_DEF(int)
my_func(int a, int b, int c, const char *x, const char *y, const char *z) {
  // do something
  return 0;
}

I want to keep MS_DEF(int) and my_func in same line

MS_DEF(int) my_func(...)

How to do? thanks

1 Answer 1

1

The TypenameMacros style option is intended exactly for such cases.

Try adding the following to your .clang-format configuration file:

TypenameMacros: ['MS_DEF']

With just that option, the formatted result is as following

#define MS_DEF(type) extern type

MS_DEF(int) my_func(int a, int b, int c, const char *x, const char *y,
                    const char *z) {
  // do something
  return 0;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.