public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: Joern Rennecke <amylaar@spamcop.net>
Cc: gcc@gcc.gnu.org
Subject: Re: extern const (Was: Re: [gcc-in-cxx]: patches from multi-target-4_4-branch)
Date: Mon, 25 May 2009 11:13:00 -0000	[thread overview]
Message-ID: <m34ov9zunt.fsf@google.com> (raw)
In-Reply-To: <20090524232321.v5panilqo84484cg-nzlynne@webmail.spamcop.net> (Joern Rennecke's message of "Sun\, 24 May 2009 23\:23\:21 -0400")

Joern Rennecke <amylaar@spamcop.net> writes:

> Quoting Ian Lance Taylor <iant@google.com>:
>> Joern Rennecke <amylaar@spamcop.net> writes:
>>> 	* config/sh/sh.c (sh_attribute_table): Use extern in forward
>>> 	declaration.
>>> Common issue with declaring/defining const variables in C++.
>>
>> I've been doing this as
>>
>> #ifdef __cplusplus
>> extern
>> #endif
>
> These #ifdefs sprinkled over the code are awkward.  Could we use a #define
> for this?  E.g. put in system.h
> #ifdef __cplusplus
> #define CONST_VAR_DECL extern const
> #else
> #define CONST_VAR_DECL const
> #endif

Yes, that is certainly the way to go if it is in fact not safe to use
"extern const int i = 1;" for all C compilers.  I hadn't planned to deal
with this issue yet, but since you bring it up, we should decide whether
that construct is safe, or whether we need the macro.

Ian

  reply	other threads:[~2009-05-25  4:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-29 13:22 gcc-in-cxx update / multi-targeted gcc Joern Rennecke
2009-04-29 13:29 ` Joseph S. Myers
2009-04-29 13:31   ` Joern Rennecke
2009-04-29 13:44     ` Joseph S. Myers
2009-04-29 13:53       ` Richard Earnshaw
2009-04-29 13:56         ` Joseph S. Myers
2009-04-29 20:18           ` Kaveh R. GHAZI
2009-04-29 15:06 ` Ian Lance Taylor
2009-04-29 17:15   ` Joseph S. Myers
2009-04-29 21:57     ` Joern Rennecke
2009-04-29 21:34   ` Joern Rennecke
     [not found]   ` <20090524121328.5bxlsmbf4cgos440-nzlynne@webmail.spamcop.net>
     [not found]     ` <m3tz3anfh8.fsf@google.com>
2009-05-25  7:54       ` extern const (Was: Re: [gcc-in-cxx]: patches from multi-target-4_4-branch) Joern Rennecke
2009-05-25 11:13         ` Ian Lance Taylor [this message]
2009-05-25 12:03           ` Joern Rennecke
2009-05-25 12:42             ` Ian Lance Taylor
2009-05-25 19:53           ` Gabriel Dos Reis
2009-05-25 19:05         ` Gabriel Dos Reis
2009-04-29 22:07 ` gcc-in-cxx update / multi-targeted gcc Esben Mose Hansen

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=m34ov9zunt.fsf@google.com \
    --to=iant@google.com \
    --cc=amylaar@spamcop.net \
    --cc=gcc@gcc.gnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).