From: Yuri Khan <yuri.v.khan@gmail.com>
To: Emanuel Berg <moasen@zoho.com>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: insert-header-preprocessor-definition
Date: Mon, 16 Apr 2018 12:35:36 +0700 [thread overview]
Message-ID: <CAP_d_8XFM2NZv0eHPZzTYsMRXqE_MY1QAwwGZRqU_OjOVwuavQ@mail.gmail.com> (raw)
In-Reply-To: <86604s9rrj.fsf@zoho.com>
On Mon, Apr 16, 2018 at 2:46 AM, Emanuel Berg <moasen@zoho.com> wrote:
>> The practical solution is, of course, the
>> same as with all name conflict issues:
>> Namespacing. That is, in your project, you
>> start all preprocessor defines with the name
>> of your project.
>
> Woah, is *that* what people mean with
> "namespacing"? I thought that was something
> more advanced!
Well, yes, I define namespacing as the means to subdivide a _space_ of
_names_ into subspaces so that names from different subspaces are
guaranteed to not clash. Each such subspace is a _namespace_.
Many languages and environments have first-class support for
namespaces. For example, in the UNIX file system, a directory is a
namespace. In C++, a fully qualified name starts with ::, followed by
namespace names separated by ::, followed by an identifier.
> I remember people using it in C++ and I removed
> it telling everyone it was a bad idea and
> instead one should use the whole path to
> identify things.
Some languages let programmers access all names in a namespace as if
they were local. In C++, “using namespace foo;”; in Python, “from foo
import *”; etc. By many coding standards and conventions, these are
discouraged, because they make it harder to reason about the complete
set of names accessible at a point, and where each name comes from.
In small scopes, wholesale importing a namespace is okay, and
sometimes even necessary.
>> On the other hand, the two or three compilers
>> out there that are most likely to be used to
>> compile your project already support
>> #pragma once.
>
> I'm on gcc 4.9. Should I get away with the
> guards and use '#pragma once' instead?
https://en.wikipedia.org/wiki/Pragma_once#Portability says GCC has
supported #pragma once since 3.4.
Of course, when you work in a team, such decisions are best taken collectively.
next prev parent reply other threads:[~2018-04-16 5:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <86fu429udy.fsf@zoho.com>
2018-04-11 15:47 ` insert-header-preprocessor-definition Ben Bacarisse
2018-04-11 20:41 ` insert-header-preprocessor-definition Emanuel Berg
2018-04-11 20:56 ` insert-header-preprocessor-definition Ben Bacarisse
2018-04-11 22:07 ` insert-header-preprocessor-definition Emanuel Berg
2018-04-14 23:54 ` insert-header-preprocessor-definition Emanuel Berg
2018-04-15 1:02 ` insert-header-preprocessor-definition Ben Bacarisse
2018-04-15 7:44 ` insert-header-preprocessor-definition Yuri Khan
2018-04-15 19:35 ` insert-header-preprocessor-definition Emanuel Berg
2018-04-15 21:10 ` insert-header-preprocessor-definition Ben Bacarisse
2018-04-15 21:45 ` insert-header-preprocessor-definition Emanuel Berg
[not found] ` <mailman.12420.1523778312.27995.help-gnu-emacs@gnu.org>
2018-04-15 19:46 ` insert-header-preprocessor-definition Emanuel Berg
2018-04-16 5:35 ` Yuri Khan [this message]
[not found] ` <mailman.12486.1523856961.27995.help-gnu-emacs@gnu.org>
2018-04-16 6:16 ` insert-header-preprocessor-definition Emanuel Berg
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=CAP_d_8XFM2NZv0eHPZzTYsMRXqE_MY1QAwwGZRqU_OjOVwuavQ@mail.gmail.com \
--to=yuri.v.khan@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=moasen@zoho.com \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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.