Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang format problems #31

Open
fiesh opened this issue Mar 28, 2018 · 4 comments
Open

Clang format problems #31

fiesh opened this issue Mar 28, 2018 · 4 comments

Comments

@fiesh
Copy link

fiesh commented Mar 28, 2018

Alas, clang-format goes rather wild when there are no semicolons present between function declarations, putting them in one line if no empty line is in between, and indenting them when there is.

As a workaround, we added the following macro that allows adding a ; after the signal macro:

#define WS_SIGNAL(...) W_MACRO_MSVC_EXPAND(WS_SIGNAL2(__VA_ARGS__, 0))
#define WS_SIGNAL2(NAME, ...)                                                        \
	W_SIGNAL2(NAME, __VA_ARGS__) struct W_MACRO_CONCAT(w_Dummy_##NAME, __LINE__) \
	{                                                                            \
	}

So now we can write void signal(bool yay) WS_SIGNAL(signal, yay);, and clang-format plays along nicely.

I suspect we might not be the only ones who run into this, so maybe there is a place for something like this in verdigris itself?

Maybe there is also a better solution than defining a dummy struct to allow adding the extra ;?

@rakhimov
Copy link
Contributor

isn't this a duplicate of #12?

@fiesh
Copy link
Author

fiesh commented Mar 29, 2018

Ah sorry, it is... I didn't see it.

@fiesh fiesh closed this as completed Mar 29, 2018
@fiesh
Copy link
Author

fiesh commented Apr 11, 2018

Well actually it isn't, I think. The solution from #12 to just append a semi colon leads to a warning in clang when -Wextra-semi is used. The solution above doesn't. (That was the reason for the macro all along, I just forgot...)

@fiesh fiesh reopened this Apr 11, 2018
@mathstuf
Copy link

FWIW, in a project I work on, we just live with the -Wextra-semi warnings. Having clang-format Just Work is better than a warning about something (generally) pretty benign. And no, // clang-format off doesn't work; clang-format still seems to track indentation from the parts it doesn't actually change to know what to do after the corresponding // clang-format on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants