Click here to Skip to main content
15,921,169 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Smarter ways to define MACRO to strings? Pin
George_George21-Nov-07 21:52
George_George21-Nov-07 21:52 
AnswerRe: Smarter ways to define MACRO to strings? Pin
toxcct21-Nov-07 21:58
toxcct21-Nov-07 21:58 
GeneralRe: Smarter ways to define MACRO to strings? Pin
CPallini21-Nov-07 22:32
mveCPallini21-Nov-07 22:32 
GeneralRe: Smarter ways to define MACRO to strings? Pin
toxcct21-Nov-07 22:35
toxcct21-Nov-07 22:35 
GeneralRe: Smarter ways to define MACRO to strings? Pin
CPallini21-Nov-07 22:46
mveCPallini21-Nov-07 22:46 
GeneralRe: Smarter ways to define MACRO to strings? Pin
jhwurmbach22-Nov-07 0:38
jhwurmbach22-Nov-07 0:38 
GeneralRe: Smarter ways to define MACRO to strings? Pin
George_George22-Nov-07 1:26
George_George22-Nov-07 1:26 
GeneralRe: Smarter ways to define MACRO to strings? [modified] Pin
jhwurmbach22-Nov-07 2:08
jhwurmbach22-Nov-07 2:08 
George_George wrote:
#define PREFIX(x) _T("FOO")##x
p = PREFIX(SecondArray [0]);


Sure.Laugh | :laugh: This would make the compiler see
p = _T("FOO")SecondArray [0];<br />
p = _T("FOO")SecondArray [1];<br />

Not exactly what you want.
Remember, we are doing text-replacement here. The C++compiler is not running. Not the slightest trace of C++ at this level!

What we are trying to use here is called the Token-Pasting Operator as I just looked up

You want to write something like
#define PREFIX( x ) _T("FOO##x")<br />
const TCHAR* SecondArray [2] = { PREFIX(FILE1), PREFIX(FILE2)};



-- modified at 8:52 Thursday 22nd November, 2007
Corrected the issue toxcct found

Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all.
Douglas Adams, "Dirk Gently's Holistic Detective Agency"

GeneralRe: Smarter ways to define MACRO to strings? Pin
toxcct22-Nov-07 2:48
toxcct22-Nov-07 2:48 
GeneralRe: Smarter ways to define MACRO to strings? Pin
jhwurmbach22-Nov-07 2:51
jhwurmbach22-Nov-07 2:51 
GeneralRe: Smarter ways to define MACRO to strings? Pin
toxcct22-Nov-07 4:18
toxcct22-Nov-07 4:18 
GeneralRe: Smarter ways to define MACRO to strings? Pin
George_George22-Nov-07 18:21
George_George22-Nov-07 18:21 
GeneralRe: Smarter ways to define MACRO to strings? Pin
jhwurmbach22-Nov-07 21:27
jhwurmbach22-Nov-07 21:27 
GeneralRe: Smarter ways to define MACRO to strings? Pin
George_George22-Nov-07 21:50
George_George22-Nov-07 21:50 
GeneralRe: Smarter ways to define MACRO to strings? Pin
jhwurmbach22-Nov-07 21:53
jhwurmbach22-Nov-07 21:53 
GeneralRe: Smarter ways to define MACRO to strings? Pin
George_George22-Nov-07 22:10
George_George22-Nov-07 22:10 
GeneralRe: Smarter ways to define MACRO to strings? Pin
George_George22-Nov-07 1:23
George_George22-Nov-07 1:23 
GeneralRe: Smarter ways to define MACRO to strings? Pin
toxcct22-Nov-07 2:45
toxcct22-Nov-07 2:45 
GeneralRe: Smarter ways to define MACRO to strings? Pin
George_George22-Nov-07 18:24
George_George22-Nov-07 18:24 
GeneralRe: Smarter ways to define MACRO to strings? Pin
toxcct22-Nov-07 21:12
toxcct22-Nov-07 21:12 
GeneralBe patient... Pin
CPallini22-Nov-07 21:21
mveCPallini22-Nov-07 21:21 
GeneralRe: Be patient... Pin
toxcct22-Nov-07 21:24
toxcct22-Nov-07 21:24 
GeneralRe: Be patient... Pin
CPallini22-Nov-07 21:55
mveCPallini22-Nov-07 21:55 
GeneralRe: Smarter ways to define MACRO to strings? Pin
George_George22-Nov-07 21:47
George_George22-Nov-07 21:47 
QuestionHow to change window size Pin
Max++21-Nov-07 20:49
Max++21-Nov-07 20:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.