I think this may be a good time to write a little about preprocessors and structures.
When you compile your code, three things happen in order:
1. the preprocessor substitutes any preprocessor macros. Those are the #define lines.
2. the compiler compiles each file with the preprocessed code to object files.
3. the linker combines the object files to an executable.
You error comes from the second step, but is caused by not doing the first step right.
When we have a C preprocessor statement like
Code:
#define CLANNAME(clan) ((clan).title)
and you then use it like this:
it will be translated by the preprocessor to
But tch is a
pointer to a char_data structure, and dereferencing it with a '.' will not work. See
stackoverflow.com/a/2575050
This results in trying to look up the "title" member in the pointer (not on the structure) and thus gives you your first error. Another problem here is that since tch is a
char_data structure, you can't use it directly here - since you need a
clan structure.
So, you try to look it up using PLAYERCLAN(tch) instead. Apparently, this returns a number. This text should give you a hint about that:
#define PLAYERCLAN(ch) ((ch)->player_specials->saved.clannum)
This then gives you your other warning - you're trying to write out to the %s format identifier, but are supplying a number.
So to the solution. I think there's at least one macro missing:
Code:
#define GET_CLAN(num) (clan_index[(num)])
Then you can do it like this:
Code:
CLANNAME(GET_CLAN(PLAYERCLAN(tch)))
Which the preprocessor will turn into
Code:
(((clan_index[((tch)->player_specials->saved.clannum)])).title)
which should compile. The amount of parenthesises here is not important - they will be ignored, generally.
However, there's a catch here. What if a person isn't in a clan? Then, probably, the clannum will be negative or 0? If it is negative, you have an issue, and need to check it before using it. If it is 0, make sure clan 0 makes sense as "no clan".