Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Madd the Sane

macrumors 6502a
Original poster
This is what I'm trying to do: I want to set a function name based on a preprocessor definition. This is my current code:
Code:
#define PLUGLOC PCSXRPLUG ## _locale_text
extern char* PLUGLOC(char* toloc);
I want PLUGLOC to be defined based on the preprocessor definition PCSXRPLUG, set at the command line. But what I'm getting is PCSXRPLUG_locale_text regardless of what PCSXRPLUG is. If I'm doing it wrong, how do I do it right?
 
You have to go through couple of levels of indirection to get PCSXRPLUG to be expanded and not used literally.

Code:
#define PLUGLOC_x(x,y) x ## y
#define PLUGLOC_y(x,y) PLUGLOC_x(x,y)
#define PLUGLOC PLUGLOC_y(PCSXRPLUG,_locale_text)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.