From: wwp <subscript@free.fr>
To: linux-c-programming@vger.kernel.org
Subject: Re: include guards
Date: Wed, 20 Jun 2007 14:43:06 +0200 [thread overview]
Message-ID: <20070620144306.727cc2ba@localhost.localdomain> (raw)
In-Reply-To: <46720AFF.6070402@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1240 bytes --]
Hello Shriramana,
On Fri, 15 Jun 2007 09:13:59 +0530 Shriramana Sharma <samjnaa@gmail.com> wrote:
> Hello.
>
> To prevent header files from being included more than once in the same
> translation unit, we use include guards like
>
> # ifndef FOO_H
> # define FOO_H
> ...
> # endif
>
> Recently I came to know that I can use simply:
>
> # pragma once
>
> instead of the above group of sentences and the desired effect is still
> accomplished.
>
> This leads me to think of two things:
>
> 1. why use the ifndef-define-endif method when the pragma once method is
> simpler and cleaner?
>
> 2. why should we need to use either method at all? If it is a
> universally undesirable behaviour that the same header file is included
> in a translation unit more than once, then an intelligent compiler (or
> preprocessor) itself can by default take of this, right?
>
> I understand that to write portable code that compiles on
> not-so-intelligent compilers, we may need to do something manually, so
> question 2 is answered, but question 1 still stands...
#pragma is simply not supported by all pre-processors, is that
directive present in any standard at least?
Regards,
--
wwp
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2007-06-20 12:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-15 3:43 include guards Shriramana Sharma
2007-06-20 12:43 ` wwp [this message]
2007-06-20 15:09 ` Steve Graegert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070620144306.727cc2ba@localhost.localdomain \
--to=subscript@free.fr \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.