.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...

Forum Thread
  Posts  
qc++ working with #define (Groups : qc : Forum : vault() : qc++ working with #define) Locked
Thread Options
numbersix
numbersix quake-c coder++
Nov 27 2014 Anchor

This pre-compiler is very obtuse! And stubborn.

This is my code segment I'm replacing with a define:

if (self.lip == 1)
{
bprint(" --- army_stand1 ->\n");
army_stand1b();
}

Pretty easy right?

You can NOT do this:

#define frpr(fcnt,frid) if (self.lip == fcnt) { bprint(" --- frid ->\n"); frid(); };

In fact you can NOT put any bprint("text"); in a define at all...

NONE of these work:

#define prlin(a) #a
#define frpr(fcnt,frid) if (self.lip == fcnt) { bprint(" --- "); bprint(prlin(frid)); bprint(" ->\n"); frid(); };
#define frpr(fcnt,frid) if (self.lip == fcnt) { bprint(" --- ##frid ->\n"); frid(); };
#define frpr(fcnt,frid) if (self.lip == fcnt) { bprint(" --- #frid ->\n"); frid(); };

// also no worky
#define prl4(a) bprint(" --- ##a ->\n");
#define frpr(fcnt,frid) if (self.lip == fcnt) { prl4(frid) frid(); };

You HAVE to do this:

#define prl2 bprint(" --- ");
#define prl3 bprint(" ->\n");

#define frpr(fcnt,frid) if (self.lip == fcnt) { prl2 bprint(#frid); prl3 frid(); };

Code:

frpr(2,army_walk1);

Thus:

--- army_walk1 ->
--- trace on: monster_army - frame: 90 - in: 0.097222 ~ 0.1
--- trace on: monster_army - frame: 91 - in: 0.097222 ~ 0.1
--- trace on: monster_army - frame: 92 - in: 0.097222 ~ 0.1


I am thinking of trying this:

#define qt2 "

#define ptest(str1) bprint(qt2test print: qt2); bprint(#str1); bprint(qt2\nqt2);

And just a followup note to anyone that starts coding with #define pseudo functions:

You can NOT have numerals [0-9] in parameters!

When I tried to compile the code with str1, it does this:

compiling client.qc
in function PlayerPostThink (line 75)
client.qc:1196: warning: Stingification ignored
client.qc:1196: error: Explicit precompiler usage when not defined str1

So I changed str1 to str and qt2 to qtt.


No worky:

#define qtt "

#define ptest(str) bprint(qtt test print: qtt); bprint(#str); bprint(qtt \n qtt);

code:

ptest(seven);

result:
compiling client.qc
in function PlayerPostThink (line 75)
client.qc:1196: error: EOF inside quote
client.qc:1196: error: Unknown punctuation
client.qc:1196: error: Unknown punctuation
client.qc:1196: error: Unknown punctuation
client.qc:1196: error: Unknown punctuation


Another interesting bit:

You _can_ put a bprint(" text "); in a macro call.

Thus:

framerloop($stand1, $stand9, hknight_stand1, 0.1,ai_stand(); bprint(" --- hknight_stand1 in loop ! \n"););

Edited by: numbersix

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.