Re: Using Google styling of #define guards

2019-07-05 Thread Ehsan Akhgari
On Wed, Jul 3, 2019 at 8:45 PM Bryce Seager van Dyk 
wrote:

> On Wednesday, July 3, 2019 at 2:27:30 PM UTC-7, Chris Peterson wrote:
> > On 7/3/2019 11:37 AM, Bryce Seager van Dyk wrote:
> > > I wanted to clarify, and discuss if needed, our styling of #define
> guards. My understanding is that we are now using Google's style in regards
> to #define guards (
> https://google.github.io/styleguide/cppguide.html#The__define_Guard). I
> believe this would mean for `dom/media/foo/bar.h` I would use a `#define
> DOM_MEDIA_FOO_BAR_H_` style guard.
> >
> > The Google style guide says:
> >
> > "The format of the symbol name should be ___H_. ...
> > For example, the file foo/src/bar/baz.h in project foo should have the
> > following guard: #ifndef FOO_BAR_BAZ_H_"
> >
> > Would our project prefix be "MOZ_"? The #define guard for
> > dom/media/foo/bar.h would then be MOZ_DOM_MEDIA_FOO_BAR_H.
>
> Good question. Chromium's code doesn't seem to observe the project
> convention in the media code I'm familiar with.


FWIW Chromium's style is heavily modified:
https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md
although in this case they follow the Google style.


> E.g.
> https://cs.chromium.org/chromium/src/media/formats/mp4/track_run_iterator.h?l=36&rcl=fb277091ba0ccbf8b2869022910573386e33c6de
> doesn't have a CHROMIUM prefix on its guard. Other directories rooted at
> chromium/src/ also appear to not have a CHROMIUM prefix used in their
> guards. Trawling some of their other projects on github I see that some do
> observe the usage of the prefix and some do not.
>
> I thought the non-project prefix version seemed the more intuitive mapping
> onto the mozilla-central structure. However, that's entirely my person
> view, and is almost certainly influenced by my reading of Chromium code.
>
> I feel much more strongly about consistency than about either particular
> style. So I appreciate hearing thoughts about what seems the
> intuitive/appropriate mapping of the guidelines onto the codebase.
>

I think the idea behind including the project name is to make it easier to
include various project headers' inside each other.  Since that may not be
a realistic concern for us, we may as well avoid the needless verbosity and
use DOM_MEDIA_FOO_BAR_H_, I think.

-- 
Ehsan
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Using Google styling of #define guards

2019-07-03 Thread Bryce Seager van Dyk
On Wednesday, July 3, 2019 at 2:27:30 PM UTC-7, Chris Peterson wrote:
> On 7/3/2019 11:37 AM, Bryce Seager van Dyk wrote:
> > I wanted to clarify, and discuss if needed, our styling of #define guards. 
> > My understanding is that we are now using Google's style in regards to 
> > #define guards 
> > (https://google.github.io/styleguide/cppguide.html#The__define_Guard). I 
> > believe this would mean for `dom/media/foo/bar.h` I would use a `#define 
> > DOM_MEDIA_FOO_BAR_H_` style guard.
> 
> The Google style guide says:
> 
> "The format of the symbol name should be ___H_. ... 
> For example, the file foo/src/bar/baz.h in project foo should have the 
> following guard: #ifndef FOO_BAR_BAZ_H_"
> 
> Would our project prefix be "MOZ_"? The #define guard for 
> dom/media/foo/bar.h would then be MOZ_DOM_MEDIA_FOO_BAR_H.

Good question. Chromium's code doesn't seem to observe the project convention 
in the media code I'm familiar with. E.g. 
https://cs.chromium.org/chromium/src/media/formats/mp4/track_run_iterator.h?l=36&rcl=fb277091ba0ccbf8b2869022910573386e33c6de
 doesn't have a CHROMIUM prefix on its guard. Other directories rooted at 
chromium/src/ also appear to not have a CHROMIUM prefix used in their guards. 
Trawling some of their other projects on github I see that some do observe the 
usage of the prefix and some do not.

I thought the non-project prefix version seemed the more intuitive mapping onto 
the mozilla-central structure. However, that's entirely my person view, and is 
almost certainly influenced by my reading of Chromium code.

I feel much more strongly about consistency than about either particular style. 
So I appreciate hearing thoughts about what seems the intuitive/appropriate 
mapping of the guidelines onto the codebase.

___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Using Google styling of #define guards

2019-07-03 Thread Chris Peterson

On 7/3/2019 11:37 AM, Bryce Seager van Dyk wrote:

I wanted to clarify, and discuss if needed, our styling of #define guards. My 
understanding is that we are now using Google's style in regards to #define 
guards (https://google.github.io/styleguide/cppguide.html#The__define_Guard). I 
believe this would mean for `dom/media/foo/bar.h` I would use a `#define 
DOM_MEDIA_FOO_BAR_H_` style guard.


The Google style guide says:

"The format of the symbol name should be ___H_. ... 
For example, the file foo/src/bar/baz.h in project foo should have the 
following guard: #ifndef FOO_BAR_BAZ_H_"


Would our project prefix be "MOZ_"? The #define guard for 
dom/media/foo/bar.h would then be MOZ_DOM_MEDIA_FOO_BAR_H.

___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform