Nathan
Nathan

Reputation: 1288

Make clang-format allow return type of function on its own line

I'm trying to figure out if I can use clang-format to automatically format the code for my project. We have a coding style which enforces newlines after the function return type (but only in the definition, not in the declaration). I'd like to encode this in clang-format.

IOW, I want this:

uint32_t
my_function(uint32_t input)
{
    return 0;
}

Not this:

uint32_t my_function(uint32_t input)
{
    return 0;
}

Upvotes: 7

Views: 8483

Answers (1)

West
West

Reputation: 742

AlwaysBreakAfterDefinitionReturnType(DRTBS_All) If you add that to the .clang-format file that contains all your formatting decisions it should do exactly what you want.

Upvotes: 12

Related Questions