* Float template parameters support in gcc3.2 [not found] <1038476880.12170.ezmlm@gcc.gnu.org> @ 2002-11-28 1:54 ` Megha Murarka 2003-04-04 10:21 ` Namespaces and pre-processing directives Megha Murarka 0 siblings, 1 reply; 4+ messages in thread From: Megha Murarka @ 2002-11-28 1:54 UTC (permalink / raw) To: gcc-help Can 'double' parameters in template be used with gcc3.2 ? is there any option for this support ? i can compile templates with 'double' parameters in gcc2.96. thanks in advanc regards, Megha ^ permalink raw reply [flat|nested] 4+ messages in thread
* Namespaces and pre-processing directives 2002-11-28 1:54 ` Float template parameters support in gcc3.2 Megha Murarka @ 2003-04-04 10:21 ` Megha Murarka 2003-04-04 10:42 ` Matthieu Moy 2003-04-04 10:45 ` Andrea 'fwyzard' Bocci 0 siblings, 2 replies; 4+ messages in thread From: Megha Murarka @ 2003-04-04 10:21 UTC (permalink / raw) To: gcc-help 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Namespaces and pre-processing directives 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 1 sibling, 0 replies; 4+ messages in thread From: Matthieu Moy @ 2003-04-04 10:42 UTC (permalink / raw) To: Megha Murarka; +Cc: gcc-help "Megha Murarka" <megha@poseidontech.com> writes: > 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 ) ???? #define are managed by the preprocessor, which isn't aware of namespaces. use const instead : const int VALUE = 50; -- Matthieu ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Namespaces and pre-processing directives 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 1 sibling, 0 replies; 4+ messages in thread From: Andrea 'fwyzard' Bocci @ 2003-04-04 10:45 UTC (permalink / raw) To: Megha Murarka; +Cc: gcc-help 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-04-04 10:45 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [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 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).