You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@impala.apache.org by Tim Armstrong <ta...@cloudera.com.INVALID> on 2018/08/01 18:48:23 UTC

#pragma once?

Todd brought up our include guards on a code review, asking why we don't
use #pragma once instead: https://gerrit.cloudera.org/#/c/10988/5 . It
sounds like Kudu has switched to it

#pragma once does seem cleaner and our GCC and Clang versions are modern
enough to support it.

What do people think about switching to that as the preferred way of
including headers only once?

- Tim

Re: #pragma once?

Posted by Jim Apple <jb...@cloudera.com.INVALID>.
Yes, definitely.

On Wed, Aug 1, 2018 at 11:48 AM Tim Armstrong
<ta...@cloudera.com.invalid> wrote:

> Todd brought up our include guards on a code review, asking why we don't
> use #pragma once instead: https://gerrit.cloudera.org/#/c/10988/5 . It
> sounds like Kudu has switched to it
>
> #pragma once does seem cleaner and our GCC and Clang versions are modern
> enough to support it.
>
> What do people think about switching to that as the preferred way of
> including headers only once?
>
> - Tim
>

Re: #pragma once?

Posted by Tim Armstrong <ta...@cloudera.com.INVALID>.
Seems like we have an informal consensus: I update the style guide to
reflect this:
https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=65868536

On Thu, Aug 2, 2018 at 3:22 AM, Zoltan Borok-Nagy <
boroknagyz@cloudera.com.invalid> wrote:

> +1 for #pragma once since it's cleaner and less error-prone.
>
> Zoltan
>
>
> On Wed, Aug 1, 2018 at 11:03 PM Todd Lipcon <to...@cloudera.com.invalid>
> wrote:
>
> > Yea, when we looked into it I recall that it worked fine on all compilers
> > from the last 10 years or something (in fact I remember using #pragma
> once
> > on Metrowerks Codewarrior more than fifteen years ago). Given we require
> > C++14 I don't think #pragma once is going to be the limiting factor in
> > compiler version portability.
> >
> > -Todd
> >
> > On Wed, Aug 1, 2018 at 12:01 PM, Sailesh Mukil
> > <sailesh@cloudera.com.invalid
> > > wrote:
> >
> > > An advantage of using #pragma once is potential improved compilation
> > > speeds. However, a con is that it's non-standard and therefore, its
> > > behavior can change at any point and can also vary across compilers,
> > > potentially making the code even less portable.
> > >
> > > That being said, since Kudu has been using it for a while and has had
> no
> > > issues, we can do the same since the potential benefits outweigh the
> > cons.
> > >
> > > On Wed, Aug 1, 2018 at 11:48 AM, Tim Armstrong <
> > > tarmstrong@cloudera.com.invalid> wrote:
> > >
> > > > Todd brought up our include guards on a code review, asking why we
> > don't
> > > > use #pragma once instead: https://gerrit.cloudera.org/#/c/10988/5 .
> It
> > > > sounds like Kudu has switched to it
> > > >
> > > > #pragma once does seem cleaner and our GCC and Clang versions are
> > modern
> > > > enough to support it.
> > > >
> > > > What do people think about switching to that as the preferred way of
> > > > including headers only once?
> > > >
> > > > - Tim
> > > >
> > >
> >
> >
> >
> > --
> > Todd Lipcon
> > Software Engineer, Cloudera
> >
>

Re: #pragma once?

Posted by Zoltan Borok-Nagy <bo...@cloudera.com.INVALID>.
+1 for #pragma once since it's cleaner and less error-prone.

Zoltan


On Wed, Aug 1, 2018 at 11:03 PM Todd Lipcon <to...@cloudera.com.invalid>
wrote:

> Yea, when we looked into it I recall that it worked fine on all compilers
> from the last 10 years or something (in fact I remember using #pragma once
> on Metrowerks Codewarrior more than fifteen years ago). Given we require
> C++14 I don't think #pragma once is going to be the limiting factor in
> compiler version portability.
>
> -Todd
>
> On Wed, Aug 1, 2018 at 12:01 PM, Sailesh Mukil
> <sailesh@cloudera.com.invalid
> > wrote:
>
> > An advantage of using #pragma once is potential improved compilation
> > speeds. However, a con is that it's non-standard and therefore, its
> > behavior can change at any point and can also vary across compilers,
> > potentially making the code even less portable.
> >
> > That being said, since Kudu has been using it for a while and has had no
> > issues, we can do the same since the potential benefits outweigh the
> cons.
> >
> > On Wed, Aug 1, 2018 at 11:48 AM, Tim Armstrong <
> > tarmstrong@cloudera.com.invalid> wrote:
> >
> > > Todd brought up our include guards on a code review, asking why we
> don't
> > > use #pragma once instead: https://gerrit.cloudera.org/#/c/10988/5 . It
> > > sounds like Kudu has switched to it
> > >
> > > #pragma once does seem cleaner and our GCC and Clang versions are
> modern
> > > enough to support it.
> > >
> > > What do people think about switching to that as the preferred way of
> > > including headers only once?
> > >
> > > - Tim
> > >
> >
>
>
>
> --
> Todd Lipcon
> Software Engineer, Cloudera
>

Re: #pragma once?

Posted by Todd Lipcon <to...@cloudera.com.INVALID>.
Yea, when we looked into it I recall that it worked fine on all compilers
from the last 10 years or something (in fact I remember using #pragma once
on Metrowerks Codewarrior more than fifteen years ago). Given we require
C++14 I don't think #pragma once is going to be the limiting factor in
compiler version portability.

-Todd

On Wed, Aug 1, 2018 at 12:01 PM, Sailesh Mukil <sailesh@cloudera.com.invalid
> wrote:

> An advantage of using #pragma once is potential improved compilation
> speeds. However, a con is that it's non-standard and therefore, its
> behavior can change at any point and can also vary across compilers,
> potentially making the code even less portable.
>
> That being said, since Kudu has been using it for a while and has had no
> issues, we can do the same since the potential benefits outweigh the cons.
>
> On Wed, Aug 1, 2018 at 11:48 AM, Tim Armstrong <
> tarmstrong@cloudera.com.invalid> wrote:
>
> > Todd brought up our include guards on a code review, asking why we don't
> > use #pragma once instead: https://gerrit.cloudera.org/#/c/10988/5 . It
> > sounds like Kudu has switched to it
> >
> > #pragma once does seem cleaner and our GCC and Clang versions are modern
> > enough to support it.
> >
> > What do people think about switching to that as the preferred way of
> > including headers only once?
> >
> > - Tim
> >
>



-- 
Todd Lipcon
Software Engineer, Cloudera

Re: #pragma once?

Posted by Sailesh Mukil <sa...@cloudera.com.INVALID>.
An advantage of using #pragma once is potential improved compilation
speeds. However, a con is that it's non-standard and therefore, its
behavior can change at any point and can also vary across compilers,
potentially making the code even less portable.

That being said, since Kudu has been using it for a while and has had no
issues, we can do the same since the potential benefits outweigh the cons.

On Wed, Aug 1, 2018 at 11:48 AM, Tim Armstrong <
tarmstrong@cloudera.com.invalid> wrote:

> Todd brought up our include guards on a code review, asking why we don't
> use #pragma once instead: https://gerrit.cloudera.org/#/c/10988/5 . It
> sounds like Kudu has switched to it
>
> #pragma once does seem cleaner and our GCC and Clang versions are modern
> enough to support it.
>
> What do people think about switching to that as the preferred way of
> including headers only once?
>
> - Tim
>