All of lore.kernel.org
 help / color / mirror / Atom feed
* constructor vs. __constructor__
@ 2023-08-24  3:24 Liu Jaloo
  2023-08-24  5:54 ` Markus Armbruster
  0 siblings, 1 reply; 4+ messages in thread
From: Liu Jaloo @ 2023-08-24  3:24 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 117 bytes --]

What's the difference between  "__attribute__((constructor))" and
"__attribute__((__constructor__))" in qemu source?

[-- Attachment #2: Type: text/html, Size: 179 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: constructor vs. __constructor__
  2023-08-24  3:24 constructor vs. __constructor__ Liu Jaloo
@ 2023-08-24  5:54 ` Markus Armbruster
  2023-08-24  9:33   ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Armbruster @ 2023-08-24  5:54 UTC (permalink / raw)
  To: Liu Jaloo; +Cc: qemu-devel

Liu Jaloo <liu.jaloo@gmail.com> writes:

> What's the difference between  "__attribute__((constructor))" and
> "__attribute__((__constructor__))" in qemu source?

Reading the fine manual helps:

    You may optionally specify attribute names with ‘__’ preceding and
    following the name.  This allows you to use them in header files
    without being concerned about a possible macro of the same name. For
    example, you may use the attribute name __noreturn__ instead of
    noreturn.

https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: constructor vs. __constructor__
  2023-08-24  5:54 ` Markus Armbruster
@ 2023-08-24  9:33   ` Peter Maydell
  2023-08-25  1:09     ` Liu Jaloo
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2023-08-24  9:33 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Liu Jaloo, qemu-devel

On Thu, 24 Aug 2023 at 06:55, Markus Armbruster <armbru@redhat.com> wrote:
>
> Liu Jaloo <liu.jaloo@gmail.com> writes:
>
> > What's the difference between  "__attribute__((constructor))" and
> > "__attribute__((__constructor__))" in qemu source?
>
> Reading the fine manual helps:
>
>     You may optionally specify attribute names with ‘__’ preceding and
>     following the name.  This allows you to use them in header files
>     without being concerned about a possible macro of the same name. For
>     example, you may use the attribute name __noreturn__ instead of
>     noreturn.

As usual in the QEMU sources, we are not particularly consistent
about using one version compared to the other. However we
mostly use the "__attribute__((foo))" form rather than
"__attribute__((__foo__))" so if you're writing new code then
prefer the former.

We also have a handful of uses of "__attribute((foo))" and
"__attribute((__foo__))". Definitely don't add more of those :-)

thanks
-- PMM


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: constructor vs. __constructor__
  2023-08-24  9:33   ` Peter Maydell
@ 2023-08-25  1:09     ` Liu Jaloo
  0 siblings, 0 replies; 4+ messages in thread
From: Liu Jaloo @ 2023-08-25  1:09 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Markus Armbruster, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1182 bytes --]

Thanks for your reply.

On Thu, Aug 24, 2023 at 5:33 PM Peter Maydell <peter.maydell@linaro.org>
wrote:

> On Thu, 24 Aug 2023 at 06:55, Markus Armbruster <armbru@redhat.com> wrote:
> >
> > Liu Jaloo <liu.jaloo@gmail.com> writes:
> >
> > > What's the difference between  "__attribute__((constructor))" and
> > > "__attribute__((__constructor__))" in qemu source?
> >
> > Reading the fine manual helps:
> >
> >     You may optionally specify attribute names with ‘__’ preceding and
> >     following the name.  This allows you to use them in header files
> >     without being concerned about a possible macro of the same name. For
> >     example, you may use the attribute name __noreturn__ instead of
> >     noreturn.
>
> As usual in the QEMU sources, we are not particularly consistent
> about using one version compared to the other. However we
> mostly use the "__attribute__((foo))" form rather than
> "__attribute__((__foo__))" so if you're writing new code then
> prefer the former.
>
> We also have a handful of uses of "__attribute((foo))" and
> "__attribute((__foo__))". Definitely don't add more of those :-)
>
> thanks
> -- PMM
>

[-- Attachment #2: Type: text/html, Size: 1775 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-25  1:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-24  3:24 constructor vs. __constructor__ Liu Jaloo
2023-08-24  5:54 ` Markus Armbruster
2023-08-24  9:33   ` Peter Maydell
2023-08-25  1:09     ` Liu Jaloo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.