Re: [RFC] UAPI: Check headers by compiling all together as C++
From: Alexey Dobriyan
Date: Thu Sep 13 2018 - 18:01:30 EST
On Wed, Sep 05, 2018 at 11:22:47PM +0100, Al Viro wrote:
> On Wed, Sep 05, 2018 at 10:31:11PM +0300, Alexey Dobriyan wrote:
> > On Wed, Sep 05, 2018 at 09:26:36PM +0200, Greg KH wrote:
> > > On Wed, Sep 05, 2018 at 09:59:22PM +0300, Alexey Dobriyan wrote:
> > > > > On Wed, Sep 05, 2018 at 04:54:27PM +0100, David Howells wrote:
> > > > > >
> > > > > > Here's a set of patches that inserts a step into the build process to make
> > > > > > sure that the UAPI headers can all be built together with C++ (if the
> > > > > > compiler being used supports C++). All but the final patch perform fixups,
> > > > > > including:
> > > > >
> > > > > Wait, why do we care? What has recently changed to start to directly
> > > > > import kernel uapi files into C++ code?
> > > >
> > > > I think David is seriously trying to compile kernel with C++ compiler
> > > > and this is first step.
> > > >
> > > > He isn't alone. Resistance is futile. :^)
> > >
> > > "struct class" is going to be a hard one to overcome :)
> >
> > "struct class" makes you hostis publicus #1 of the Linux++ empire. :^)
>
> Don't tempt me...
<= g++-8 doesn't support C99 style initializers.
g++-8 mostly does: for example
.foo = {
[BAR] = 1,
},
doesn't work, but regular .foo = 42 does.
Additionally, g++ makes noise about order of initializators.
C++20 is supposed to make things better.
g++ supports -fpermissive which is a blessing.
clang doesn't support -fpermissive which makes everything way more
tedious and it has problems with alternatives (and IIRC vdso code).
Now with gcc version bumped recently I think __attribute__((cleanup))
is supported which makes destructor-like behaviour possible:
with_spinlock(&p->l) {
return 0;
}
with_mutex(&m) {
}
with_rcu() {
}