Properly use #include <> and #include ""
Michael Olbrich
michael-olbrich at web.de
Sun Jun 17 18:15:31 BST 2007
On Sat, Jun 16, 2007 at 11:41:07AM +0200, Matthias Kretz wrote:
> Can you make your example a bit more concrete? So far it looks designed to
> break. Any real world examples?
>
> Have you read the rationale on
> http://techbase.kde.org/Policies/Library_Code_Policy#As_library_developer ?
I have, and I think it is wrong. To use the given example: I think
"g++ -I/usr/include/anotherlib -I/usr/include/libxyz ..." should
_always_ fail.
The problem is the following:
Many libraries use the same method to generate the include guards. This
means there is a high probability that /usr/include/libzyx/foo.h and
/usr/include/anotherlib/foo.h have the same guard.
Now in the source you are trying to compile most files contain
#include <xyz.h>
only.
Some files however contain
#include <foo.h>
#include <xyz.h>
most likely because "#include <xyz.h>" was added after
"#include <foo.h>" was already there.
For someone who doesn't know the code this looks like "foo.h" is
randomly not included. An error that is much more difficult to find.
If we use <> instead, all source files will break and the error is much
easier to recognize.
michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070617/b534497a/attachment.sig>
More information about the kde-core-devel
mailing list