#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?
Yes, definitely. On Wed, Aug 1, 2018 at 11:48 AM Tim Armstrong 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?
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 < tarmstr...@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?
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 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 < > tarmstr...@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?
+1 for #pragma once since it's cleaner and less error-prone. Zoltan On Wed, Aug 1, 2018 at 11:03 PM Todd Lipcon 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 > > 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 < > > tarmstr...@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?
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 < borokna...@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 > 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 > > > > 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 < > > > tarmstr...@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 > > >