.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...

Post feature Report content RSS feed Compiler warnings and quake-c

How important are compiler warnings? With 2 code sets released to base mods on with the express purpose of being warning free, its time to exhort the importance of clearing out compiler warnings.

Posted by on

The original quake-c v106 release had a few compiler warnings. Heck, get any open source or free code and compile it - chances are you will see some warnings.

Do they warrant attention or repair? That depends.
After all, the code compiles and runs. A cursory inspection may not even reveal any fault with it...

The most important question is - does anything break?

With quake-c you need to be aware that warnings can affect code operation - here is an example from the 1.06 code found in misc.qc:

misc.qc(201): warning: No operation performed

Code:

void() misc_fireball =
{
...
if (!self.speed)
self.speed == 1000; // *** this caused the warning
}

What should this code do?

A: if a misc_fireball entity is loaded on a map by this spawn function and no speed is set, a default of 1000 gets set.

What is wrong here?

A: "==" is a conditional test and not an assignment operator.

This code does NOT assign 1000 to self.speed!

To verify this - coded added to function to set a global we can check

float lastsp; // add above function
...
lastsp = self.speed; // put after assignment

Now load any map that has a misc_fireball with no set speed.
For this example I cheated with an additional code mod:

// if (!self.speed)

This does not rely on the map entity and always does the assignment.
NOTE: prvm_global is a darkplaces console command.

warning code:

]prvm_global server lastsp
lastsp: 350.0000

fixed code:

]prvm_global server lastsp
lastsp: 1000.0000

How does this code actually affect the game?

It turns out 350 - 700 is a much better fireball launch speed. 1000 is kind of fast. That may be why this compiler warning never got fixed.

This is just an example, however. If your quake-c has compiler warnings that could be why it is not performing as you expect. This exact conditional non assignment error has caused me headaches in the past. I fixed it easy because I always maintain my quake-c code warning free.

Post a comment
Sign in or join with:

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.

Established
Privacy
Public
Subscription
Open to all members
Contact
Send Message
Homepage
Moddb.com
Membership
Join group
Group watch
Start tracking
Feature
Browse
Features
Share
Related Games
Quake
Quake First Person Shooter
Related Engines
Quake Engine
Quake Engine GPL
Related Groups
id Software
id Software Developer & Publisher with 2 members
qc
qc Hardware & Tech with 31 members