Skip to content

[clang-format] Pointer alignment option for function return types #136597

Open
@oajlouni

Description

@oajlouni

This is a simple example to explain what I mean:

char* alloc_str(int size)
{
    char *str = malloc(size);

    return str;
}

I'd like to have my code formatted in a way that a pointer is right-aligned in a variable declaration and left-aligned if it is a return type.

Having read through Clang-Format Style Options, the only two options I've found were DerivePointerAlignment and PointerAlignment and they only seem to treat all pointers the same way.

Is there a way to achieve what I'm after? Or could this be worth considering as a new feature?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions