Formatting breaks line before function definitions

I have some code that looks like

 

SOME_ANNOTATION_MACRO()

int foo()
{
    return 0;
}

 

But I can't seemingly get R# formatter not to add a new line between the macro and the function declaration, i.e. formatting results in:

 

SOME_ANNOTATION_MACRO()




int foo()
{
    return 0;
}

 

Apparently they get treated as 2 functions definitions (the macro and foo), and forcing no extra line break between function definitions is the only work around I found for this issue. Problem is, I want to keep some space between function definitions, and I wonder if this is a known issue and if there's a solution for this.

 

3 comments

Hello,

What does the annotation macro expand to?

0

well, that depends on the compiler, this is the macro I'm using:

#if !defined(GG_BIND)
#if !defined(__clang__)
#define GG_BIND(...)
#else
#define GG_BIND(...) __attribute__((annotate("bind:{" #__VA_ARGS__ "}")))
#endif // !defined(__clang__)
#endif // !defined(GG_BIND)
0

This is a bug, I've filed https://youtrack.jetbrains.com/issue/RSCPP-25325.

As a workaround you can either put the annotation on the same line as the function definition, or make it non-empty just for R++:

#ifdef __RESHARPER__
#define GG_BIND(...) __declspec()
#else
#if !defined(GG_BIND)
#if !defined(__clang__)
#define GG_BIND(...)
#else
#define GG_BIND(...) __attribute__((annotate("bind:{" #__VA_ARGS__ "}")))
#endif // !defined(__clang__)
#endif // !defined(GG_BIND)
#endif
0

Please sign in to leave a comment.