Skip to contentSkip to conversation

Consider supporting building with clang

DISCUSSION [email protected] 3 participants 3 messages May 12, 2021 – May 14, 2021

lore
Share & tools
lore
#0 lore raw

Hello,

Since the introduction of the _auto_ destructor macros, ell and iwd generate nested functions, which are a gnu extension not supported by clang.

While adding support for that in clang would also benefit other projects, I don't think this idea is going anywhere as it has been brought up numerous times in the past and never went forward.

The way e.g. glib deals with it is by splitting this in two, first define the destructor function alonside the struct it is going to destruct, then hook it up with a macro like _auto_ here, this way no nested functions are needed. Would this make sense for ell/iwd too? I can provide patches if required.

#1 lore raw
Quoted 8 lines · On Wed, May 12, 2021 at 4:47 AM <[email protected]> wrote:

Hello,

Since the introduction of the _auto_ destructor macros, ell and iwd generate nested functions, which are a gnu extension not supported by clang.

While adding support for that in clang would also benefit other projects, I don't think this idea is going anywhere as it has been brought up numerous times in the past and never went forward.

The way e.g. glib deals with it is by splitting this in two, first define the destructor function alonside the struct it is going to destruct, then hook it up with a macro like _auto_ here, this way no nested functions are needed. Would this make sense for ell/iwd too? I can provide patches if required.

C23 will get support for lambdas I believe.

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2638.pdf

Quoted 3 lines

_______________________________________________
iwd mailing list -- iwd(a)lists.01.org
To unsubscribe send an email to iwd-leave(a)lists.01.org

#2 lore raw
In reply to [email protected]

Hi,

Quoted 5 lines · On 5/12/21 6:47 AM, keruspe+ml01(a)gmail.com wrote:

Hello,

Since the introduction of the _auto_ destructor macros, ell and iwd generate nested functions, which are a gnu extension not supported by clang.

While adding support for that in clang would also benefit other projects, I don't think this idea is going anywhere as it has been brought up numerous times in the past and never went forward.

We're aware of this. We'll take a look at this in the next few releases.

Quoted 2 lines

The way e.g. glib deals with it is by splitting this in two, first define the destructor function alonside the struct it is going to destruct, then hook it up with a macro like _auto_ here, this way no nested functions are needed. Would this make sense for ell/iwd too? I can provide patches if required.

Yes, we considered that. However, at first glance this seemed less than ideal since our headers are not set up to make this approach very easy. Using gcc's nested function syntax made for a much more compact and less invasive change. Maybe we missed something. Feel free to take a stab at fixing this, patches are always welcome.

Regards,
-Denis