On 3/16/22 13:32, Stefan Hajnoczi wrote:
You can define rules and a way to enforce a subset of C++, but I think
over time the code will be C++. A policy that is complicated discourages
contributors.
For these reasons I think that if code runs through a C++ compiler we
should just allow C++. Either way, it will take time but that way no one
will feel betrayed when C++ creeps in.
Fair enough. We even already have some conventions that will make any
C++ that creeps in less weird (for example, mandatory typedef of structs).
I don't think it would be a big deal overall. I actually agree that we
should "just allow C++", what matters more to have style rules that make
QEMU's flavors of C and C++ consistent.
Most files are leaves (i.e. they just expose an interface via
type_init/block_init/etc.), where almost always people will copy from
something that already exists and which will be C. What matters are the
core APIs, and maintainers have way more authority there to say no to
code they're not comfortable reviewing. This way, code within a
subsystem will keep some consistency.
Paolo