1
This compiles fine....of course just some standard defines...

#define PLAYER1_NAME KEN #define PLAYER1_JOY JoystickKEN #define PLAYER1_GFX (spriteInfo*)KEN #define PLAYER1_PAL (paletteInfo*)KEN_Palettes
Curious if something like this is possible...I believe the syntax is right but I can't compile it via NeoDev

#define PLAYER1_NAME KEN #define PLAYER1_JOY Joystick##PLAYER1_NAME #define PLAYER1_GFX (spriteInfo*)PLAYER1_NAME #define PLAYER1_PAL (paletteInfo*)PLAYER1_NAME##_Palettes
The point is to just declare a character name and the prepocessor does the rest.
2
I think GCC will always place a space after a token replacement, even when using ##

Put int blah=PLAYER1_PAL; in some file, then check the output with gcc -E file.c

Workaround:
#define PLAYER1_NAME KEN #if PLAYER1_NAME==KEN #define PLAYER1_JOY JoystickKEN #define PLAYER1_GFX (spriteInfo*)KEN #define PLAYER1_PAL (paletteInfo*)KEN_Palettes #endif #if PLAYER1_NAME==ASS #define PLAYER1_JOY JoystickASS #define PLAYER1_GFX (spriteInfo*)ASS #define PLAYER1_PAL (paletteInfo*)ASS_Palettes #endif
Or put pointers into tables and define the index.
3
Hi HPMAN!

I am sad it can't be done but I had to ask.

Definately appreciate your suggestio but in my case I am trying to avoid adding the player name to the three lines below it.

I will need to define several players as unique defines. I don't need to selectively choose from multiple options for player one.

I have generic functions I am trying to pass the variables to. I am doing this so the bottom code is reusable and the defines up top control the reusable stuff.

I got tired of building separate directories for separate projects so I have all my projects building under one folder based on a variable defined in main this uses the technique you shared definitely useful stuff!
4
You can do what you ask for in post ./1, but it is a bit ugly:
https://stackoverflow.com/a/1489985
avatarZeroblog

« Tout homme porte sur l'épaule gauche un singe et, sur l'épaule droite, un perroquet. » — Jean Cocteau
« Moi je cherche plus de logique non plus. C'est surement pour cela que j'apprécie les Ataris, ils sont aussi logiques que moi ! » — GT Turbo
5
Thanks very much for your help on this one Zerosquare!
I thought all hope was lost but...doh...sadly I am still feeling this way.

ok so I want this function title

JoystickRYU

This compiles based on the gangster shit you sent me

#define JOY Joystick #define PLAYER1_NAME1 RYU #define JOY_FUNC() JOY/**/PLAYER1_NAME1
However if I call it....

JOY_FUNC() (&player->p[PLAYER1], scrollerE, boxE, fix);
I get the error "Joystick" is undeclared....
I also get an error before a weird number on the same line. I looked it up and it represents the RYU GFX.

Functions/Define/Custom.h: In function `CustomPlayerControls': Functions/Define/Custom.h:286: `Joystick' undeclared (first use in this function) Functions/Define/Custom.h:286: (Each undeclared identifier is reported only once Functions/Define/Custom.h:286: for each function it appears in.) Functions/Define/Custom.h:286: parse error before `0x002048be'
This means both Joystick and RYU are making it to the paste point but they are not concatenated....

F-bomb yo
6
You need to keep the extra steps, otherwise the C compiler won't replace JOY and PLAYER1_NAME1 with their values: #define JOY Joystick #define PLAYER1_NAME1 RYU #define PASTER(x,y) x ## y #define EVALUATOR(x,y) PASTER(x,y) #define JOY_FUNC EVALUATOR(JOY,PLAYER1_NAME1)
Then you can call your function like this:JOY_FUNC(&player->p[PLAYER1], scrollerE, boxE, fix);
avatarZeroblog

« Tout homme porte sur l'épaule gauche un singe et, sur l'épaule droite, un perroquet. » — Jean Cocteau
« Moi je cherche plus de logique non plus. C'est surement pour cela que j'apprécie les Ataris, ils sont aussi logiques que moi ! » — GT Turbo
7
Incredible ZeroSquare! THANK YOU! rotfl

Works like a charm however if RYU = GFX file then you will get a few errors to the effect of....

undefined reference to `Joystick0x002048be'

The solution is don't concatenate your GFX names to your functions and you will be fine...

Honestly I had given up! Thanks Again! ciao
8
You're welcome ^^
avatarZeroblog

« Tout homme porte sur l'épaule gauche un singe et, sur l'épaule droite, un perroquet. » — Jean Cocteau
« Moi je cherche plus de logique non plus. C'est surement pour cela que j'apprécie les Ataris, ils sont aussi logiques que moi ! » — GT Turbo