From: "Andrea 'fwyzard' Bocci" <fwyzard-gcc@libero.it>
To: "Megha Murarka" <megha@poseidontech.com>
Cc: "gcc-help" <gcc-help@gcc.gnu.org>
Subject: Re: Namespaces and pre-processing directives
Date: Fri, 04 Apr 2003 10:45:00 -0000 [thread overview]
Message-ID: <5.2.0.9.2.20030404124154.01a01118@popmail.libero.it> (raw)
In-Reply-To: <002101c2fa93$c520e8c0$1801a8c0@blr.vsnl.net.in>
At 15.49 04/04/2003 +0530, Megha Murarka wrote:
>Hi All,
>
>The program given below compiles fine.
>but if we use the statement ,
>int x = MYSPACE::VALUE +1;
> It gives an error. Why is it so ? (when the #define is present inside the
>scope of the namespace ) ????
>****************************************************************************
>**
>namespace MYSPACE{
> #define VALUE 50;
>};
>int main(){
> int x = VALUE + 1;
> return 1;
>}
>
>Regards,
>Megha
#define's are handled by the preprocessor, and like macros are unaffected
by namespaces, classes, etc.
If you try to use them, the compilersees:
>namespace MYSPACE{
>};
>int main(){
> int x = MYSPACE::50 + 1;
> return 1;
>}
which has not much sense...
If you need to use namespaces for constants, use enumes instead:
namespace MYSPACE{
enum {
VALUE = 50
};
};
int main(){
int x = MYSPACE::VALUE + 1;
return 1;
}
works.
fwyzard
prev parent reply other threads:[~2003-04-04 10:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1038476880.12170.ezmlm@gcc.gnu.org>
2002-11-28 1:54 ` Float template parameters support in gcc3.2 Megha Murarka
2003-04-04 10:21 ` Namespaces and pre-processing directives Megha Murarka
2003-04-04 10:42 ` Matthieu Moy
2003-04-04 10:45 ` Andrea 'fwyzard' Bocci [this message]
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=5.2.0.9.2.20030404124154.01a01118@popmail.libero.it \
--to=fwyzard-gcc@libero.it \
--cc=gcc-help@gcc.gnu.org \
--cc=megha@poseidontech.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.
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).