.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...
Posts | ||
---|---|---|
qc++ #define constants | Locked | |
Thread Options | ||
|
Nov 23 2014 Anchor | |
I have wrote code complicated enough to break the qcc compilers I use. How? 18221 numglobaldefs (of 32768) Quake-c has a limit on global variables! What does qcc consider a global? - any constant, if used note: compiler optimizations may (or may not) remove some of these What doesnt count? The more complex your code, the closer you come to that 32768 limit. I tried to recode qcc and the engine once. It broke the engine. Or you had to recompile every single progs.dat you run on it. (I know that can be adjusted, but the point is this is a difficult thing to change...) What can a coder do? How about #define for constants. From the fteqcc faq:
So, I checked fteqcc source for this. I could not find it. // items Those are 9 globals if used. (v106 only uses 8 ) #define IT_AXE 4096 The code looks exactly the same. In essence these are true constants. Does it change other compile stats? - Yes: global constants: 88356 strofs (of 1000000) define constants: 88244 strofs (of 1000000) Some space savings happens as well. Hints: You need at the least this one global constant: string null_string = ""; // saves many globals And in a function: if (s1 == null_string)... - this avoids the "" counting as new globals issue. DO NOT: define null_string "" Why? - the compiler sees that as "" - and count it as a new global for every local use! Now, go replace some global constants... Edited by: numbersix |
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.