Add Clang-Format Configuration File for wxWidgets Coding Style (PR #25942)

30 views
Skip to first unread message

Eran Ifrah

unread,
Oct 31, 2025, 11:11:53 AM (10 days ago) Oct 31
to wx-...@googlegroups.com, Subscribed

Introduce a .clang-format configuration file to enforce consistent code formatting across the project. This configuration is based on the wxWidgets coding style and will enable automatic code formatting with clang-format.

The configuration enforces the following key formatting rules:

  • 4-space indentation (no tabs)
  • Custom brace wrapping with braces on new lines for most constructs (classes, functions, control statements, etc.)
  • 80-character line limit
  • Spaces inside parentheses for conditional statements
  • Left-aligned pointers and references
  • No short-form single-line functions, if statements, or loops
  • One parameter per line for function declarations

This will help maintain consistent code style across contributors and reduce manual formatting effort during code reviews. Developers can now use clang-format to automatically format their code according to project standards.


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/25942

Commit Summary

  • 0acd517 Add Clang-Format Configuration File for wxWidgets Coding Style

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25942@github.com>

VZ

unread,
Oct 31, 2025, 11:16:10 AM (10 days ago) Oct 31
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25942)

Sorry, I'm against it. We may discuss this more on wx-dev, but I have 2 problems:

  1. We need to reformat all the existing code for this to be really useful and it will introduce an enormous amount of changes and break any still pending PRs/patches (hopefully few, but non zero) and complicate cherry picking fixes in 3.2.
  2. Clang-format is, how to put it politely, not very smart. It often reformats the code, especially multiline statements, in a very ugly and unreadable way. It's certainly much worse than any other auto-formatter I've used for other languages :-(

We could probably live with (2), but (1) is just a too high price to pay IMO.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25942/c3473542614@github.com>

Eran Ifrah

unread,
Oct 31, 2025, 11:18:46 AM (10 days ago) Oct 31
to wx-...@googlegroups.com, Subscribed
eranif left a comment (wxWidgets/wxWidgets#25942)

Do you have an alternative tool? it's hard to follow wxWidgets coding style :), I saw .editorconfig in the root folder but it seems no relevant. What tool do you use? (if you use one at all...)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25942/c3473555969@github.com>

Eran Ifrah

unread,
Oct 31, 2025, 11:23:28 AM (10 days ago) Oct 31
to wx-...@googlegroups.com, Subscribed
eranif left a comment (wxWidgets/wxWidgets#25942)

I would like to contribute more, but I don't like iterating PRs because of coding style ...
For example in the recent wxStyledTextCtrlMinMap - I want to add a constructor that allows the caller to control the "mini-map" size, i.e. I would like to add another constructor (or modify the current one) so I can pass: pos, size, style etc). Adding such a long constructor got me thinking: do I need to place each param on a line of its own, or?

So having a tool (does not have to be clang-format) - would be great...


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25942/c3473575022@github.com>

VZ

unread,
Oct 31, 2025, 11:23:44 AM (10 days ago) Oct 31
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25942)

I use directory-specific autocommands in Vim, but this doesn't take care of everything, just the basics. Mostly I just don't find it hard to write the code in the ambient style at all.

But I realize the value of the formatters. It's just that to really use them we need to set up a check that all new code follows the rules. And this requires reformatting all the existing code. And that, in turn, just seems a too high price to pay. FWIW all my new projects do use clang-format, for better or (mostly) worse. But the only time I've tried to switch an existing project (smaller and much younger) to it, it was a catastrophe — not because of clang-format itself but because of all the later problems it caused.

Weird idea of the day: any LLM should probably be able to "reformat the code in wxWidgets style" for you without any problems.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25942/c3473576085@github.com>

Eran Ifrah

unread,
Oct 31, 2025, 11:26:32 AM (10 days ago) Oct 31
to wx-...@googlegroups.com, Subscribed
eranif left a comment (wxWidgets/wxWidgets#25942)

Weird idea of the day: any LLM should probably be able to "reformat the code in wxWidgets style" for you without any problems.

How do you think I created that .clang-format ? 🤣Claude did that for me ...


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25942/c3473589340@github.com>

VZ

unread,
Oct 31, 2025, 11:27:46 AM (10 days ago) Oct 31
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25942)

I would like to contribute more, but I don't like iterating PRs because of coding style ...

Certainly nothing prevents you from having this file in your fork, and setting up clang-format to run it on just the new code.

I want to add a constructor that allows the caller to control the "mini-map" size, i.e. I would like to add another constructor (or modify the current one) so I can pass: pos, size, style etc). Adding such a long constructor got me thinking: do I need to place each param on a line of its own, or?

Basically just looking at any existing wxWindow-derived class ctor shows that the answer is "yes".


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25942/c3473593504@github.com>

Randalph

unread,
Oct 31, 2025, 12:13:10 PM (10 days ago) Oct 31
to wx-...@googlegroups.com
I took a slightly different approach and had Claude generate a 476-line copilot-instructions.md document that describes how an AI Agent should format any code to match wxWidgets style. I then added the name to .git/info/exclude. I'm figuring I can use that to either format or verify that I have formatted PRs in the correct wxWidgets style. The downside is that it isn't available to anyone else, any more than Eran's .clang-format is.

Like VZ, I am often annoyed by what clang-format does, though if it's truly awful I use // clang-format off // clang-format on blocks and hand format it.

--
You received this message because you are subscribed to the Google Groups "wx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-dev+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/wx-dev/wxWidgets/wxWidgets/pull/25942/c3473593504%40github.com.

Vadim Zeitlin

unread,
Nov 2, 2025, 12:28:19 PM (8 days ago) Nov 2
to wx-...@googlegroups.com
On Fri, 31 Oct 2025 09:12:51 -0700 Randalph wrote:

R> I took a slightly different approach and had Claude generate a 476-line
R> copilot-instructions.md document that describes how an AI Agent should
R> format any code to match wxWidgets style. I then added the name to
R> .git/info/exclude. I'm figuring I can use that to either format or verify
R> that I have formatted PRs in the correct wxWidgets style. The downside is
R> that it isn't available to anyone else, any more than Eran's .clang-format
R> is.

Maybe we could make this file (or both of them) available somewhere under
"misc" directory. I don't know how likely would anyone to find it there,
but at least we could point people to it.

Regards,
VZ

VZ

unread,
Nov 7, 2025, 1:19:53 PM (3 days ago) Nov 7
to wx-...@googlegroups.com, Subscribed

Closed #25942.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25942/issue_event/20794831254@github.com>

VZ

unread,
Nov 7, 2025, 1:19:54 PM (3 days ago) Nov 7
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25942)

I don't think we're going to merge this, so closing, but it could be still nice to make this available somewhere if anybody else finds it useful.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25942/c3504093349@github.com>

Reply all
Reply to author
Forward
0 new messages