[bind10-dev] coding guidelines
JINMEI Tatuya / 神明達哉
jinmei at isc.org
Wed Oct 17 20:40:55 UTC 2012
At Wed, 17 Oct 2012 19:55:32 +0000,
Francis Dupont <fdupont at isc.org> wrote:
> > > => you can assume but you can't prove... this is my point.
> >
> > I still don't get it. In theory, we can't prove that because it may
> > be implementation defined.
>
> => not only: the problem is the < > fallback rule. If an error makes
> a header file not available "locally" but available in an include
> path (i.e., " " vs < >) then there is no direct (e.g., a warning
> or better raised) way to detect it.
Ah, okay, I'm finally getting the idea....let me go back to (a
slightly modified version of) my previous example. Below, I only
consider the "practical" case, ignoring theoretical difference between
compilers.
Assume we have
lib/dir1/foo.cc
lib/dir1/foo.h
and
lib/dir2/foo.h
lib/dir2/boo.h
(but there's no lib/dir1/boo.h)
Case 1: assume we use -Ilib/dir1 and -Ilib/dir2 (in some unknown
order) for build,
1-a: if we use '#include "foo.h"' in foo.cc, we can be sure dir1/foo.h
will be used.
1-b: if we use '#include <foo.h>' in foo.cc, it may mean
lib/dir1/foo.h or lib/dir2/foo.h depending on the ordering of
-Ilib/dir1 and -Ilib/dir2, and can lead to a non-desirable
result (build failure in the luckiest case, some strange run time
behavior in the worst case)
1-c: if we typo foo.h and incorrectly type in boo.h, then
lib/dir2/boo.h will be incorrectly included whether we specify it
as "boo.h" or <boo.h>, which can lead to a non-desirable result.
Case 2: assume we use -Ilib (but not specific further, like
-Ilib/dir1)
2-a: for dir1/foo.h, we specify <dir1/foo.h>. We can be sure
lib/dir1/foo.h will be used.
2-b: it's basically impossible to confuse dir1/foo.h with dir2/foo.h as
long as we carefully control not to be too specific with the -I
option.
2-c: if we incorrectly type in <dir1/boo.h>, build will fail and we
can immediately know the error.
And, (my guess of) your points are:
- The problem like case 1-b could be solved with <>, like the case in
2-a, so you don't see a clear advantage in using "".
- You prefer <> over "" because "" cannot handle cases like 1-c but <>
can avoid like as shown in 2-c.
Am I now understanding it correctly?
---
JINMEI, Tatuya
More information about the bind10-dev
mailing list