Board index » cppbuilder » Using ## operator

Using ## operator


2005-05-26 01:30:09 PM
cppbuilder89
Hi,
I defined a macro
#define SET_STRING(this_string) l_pcString = "##this_string##";
and used it in code
SET_STRING(abc)
and expected
l_pcString = "abc";
but got
l_pcString = ""##this_string##";
How can I get the expected result ?
Thanks
\(0_o)/
 
 

Re:Using ## operator

Hi,
I defined a macro
#define SET_STRING(this_string) l_pcString = "##this_string##";
and used it in code
SET_STRING(abc)
and expected
l_pcString = "abc";
but got
l_pcString = ""##this_string##";
How can I get the expected result ?
Thanks
\(0_o)/
 

Re:Using ## operator

"\(0_o)/" < XXXX@XXXXX.COM >wrote in message
Quote
#define SET_STRING(this_string) l_pcString = "##this_string##";
[...]
SET_STRING(abc)

and expected

l_pcString = "abc";

but got

l_pcString = ""##this_string##";

How can I get the expected result ?
#define SET_STRING(this_string) l_pcString = #this_string;
Cheers,
Serge
 

{smallsort}

Re:Using ## operator

It works !! Thanks !!
"Sergiy Kanilo" < XXXX@XXXXX.COM >在郵件
Quote

"\(0_o)/" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>#define SET_STRING(this_string) l_pcString = "##this_string##";
[...]
>SET_STRING(abc)
>
>and expected
>
>l_pcString = "abc";
>
>but got
>
>l_pcString = ""##this_string##";
>
>How can I get the expected result ?

#define SET_STRING(this_string) l_pcString = #this_string;

Cheers,
Serge


 

Re:Using ## operator

\(0_o)/ < XXXX@XXXXX.COM >wrote:
Quote
Hi,

I defined a macro

#define SET_STRING(this_string) l_pcString = "##this_string##";

and used it in code

SET_STRING(abc)

and expected

l_pcString = "abc";

but got

l_pcString = ""##this_string##";

How can I get the expected result ?
#define SET_STRING(this_string) l_pcString = #this_string;
A simple '#' in front will make a srting from a
macro arg.
Quote
Thanks

\(0_o)/
Schobi
--
XXXX@XXXXX.COM is never read
I'm Schobi at suespammers dot org
"Coming back to where you started is not the same as never leaving"
Terry Pratchett
 

Re:Using ## operator

\(0_o)/ < XXXX@XXXXX.COM >wrote:
Quote
It works !! Thanks !!
[...]
Please don't multipost! I had jaust answered your
question in borland.public.cbuilderx.language.cpp.
Schobi
--
XXXX@XXXXX.COM is never read
I'm Schobi at suespammers dot org
"Coming back to where you started is not the same as never leaving"
Terry Pratchett
 

Re:Using ## operator

Got it. Thanks!
"Hendrik Schober" < XXXX@XXXXX.COM >在郵件
Quote
\(0_o)/ < XXXX@XXXXX.COM >wrote:
>Hi,
>
>I defined a macro
>
>#define SET_STRING(this_string) l_pcString = "##this_string##";
>
>and used it in code
>
>SET_STRING(abc)
>
>and expected
>
>l_pcString = "abc";
>
>but got
>
>l_pcString = ""##this_string##";
>
>How can I get the expected result ?

#define SET_STRING(this_string) l_pcString = #this_string;

A simple '#' in front will make a srting from a
macro arg.

>Thanks
>
>\(0_o)/


Schobi

--
XXXX@XXXXX.COM is never read
I'm Schobi at suespammers dot org

"Coming back to where you started is not the same as never leaving"
Terry Pratchett



 

Re:Using ## operator

Sorry...I won't do it again...
"Hendrik Schober" < XXXX@XXXXX.COM >在郵件
Quote
\(0_o)/ < XXXX@XXXXX.COM >wrote:
>It works !! Thanks !!
>[...]

Please don't multipost! I had jaust answered your
question in borland.public.cbuilderx.language.cpp.

Schobi

--
XXXX@XXXXX.COM is never read
I'm Schobi at suespammers dot org

"Coming back to where you started is not the same as never leaving"
Terry Pratchett