#pragma once?

Hi,

I'm adding a header to the build, and I'm wondering: Can we use pragma once?

I don't see it anywhere in the build except third-party paths and:

  dom/svg/nsISVGPoint.h
  xpcom/io/nsAnonymousTemporaryFile.h

So I'm not sure if it's because it's somehow prohibited or not
recommended, or just because of inertia.

 -- Emilio
0
UTF
10/11/2017 9:45:54 AM
mozilla.dev.platform 6002 articles. 0 followers. Post Follow

2 Replies
12 Views

Similar Articles

[PageSpeed] 47

On 11-10-17 11:45, Emilio Cobos Álvarez wrote:
> Hi,
> 
> I'm adding a header to the build, and I'm wondering: Can we use pragma once?
> 
> I don't see it anywhere in the build except third-party paths and:
> 
>   dom/svg/nsISVGPoint.h
>   xpcom/io/nsAnonymousTemporaryFile.h
> 
> So I'm not sure if it's because it's somehow prohibited or not
> recommended, or just because of inertia.

It's covered in our Coding Style:
https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#CC_practices

The #pragma is non-standard (though fairly widely supported), but the
"portable" way is recognized as equivalent for several compilers. It
actually seems MSVC is the only one that we (still) use that doesn't
know about the equivalence.

-- 
GCP
0
Gian
10/12/2017 3:16:36 PM
On Thu, Oct 12, 2017 at 8:16 AM, Gian-Carlo Pascutto <gcp@mozilla.com>
wrote:

> On 11-10-17 11:45, Emilio Cobos =C3=81lvarez wrote:
> > Hi,
> >
> > I'm adding a header to the build, and I'm wondering: Can we use pragma
> once?
> >
> > I don't see it anywhere in the build except third-party paths and:
> >
> >   dom/svg/nsISVGPoint.h
> >   xpcom/io/nsAnonymousTemporaryFile.h
> >
> > So I'm not sure if it's because it's somehow prohibited or not
> > recommended, or just because of inertia.
>
> It's covered in our Coding Style:
> https://developer.mozilla.org/en-US/docs/Mozilla/Developer_
> guide/Coding_Style#CC_practices
>
> The #pragma is non-standard (though fairly widely supported), but the
> "portable" way is recognized as equivalent for several compilers. It
> actually seems MSVC is the only one that we (still) use that doesn't
> know about the equivalence.
>

To be fair, the Coding Style doesn't mention `#pragma once`, nor does it
have the discussion provided by gcp.  Should it be added?

Nick
0
Nicholas
10/12/2017 3:48:28 PM
Reply: