Strict Standards: Redefining already defined constructor for class wpdb in /home/bombmin/bombinator.com/gamedev/wp-includes/wp-db.php on line 57

Deprecated: Assigning the return value of new by reference is deprecated in /home/bombmin/bombinator.com/gamedev/wp-includes/cache.php on line 36

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /home/bombmin/bombinator.com/gamedev/wp-includes/cache.php on line 384

Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl($output) in /home/bombmin/bombinator.com/gamedev/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl($output) in /home/bombmin/bombinator.com/gamedev/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el($output) in /home/bombmin/bombinator.com/gamedev/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el($output) in /home/bombmin/bombinator.com/gamedev/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el($output) in /home/bombmin/bombinator.com/gamedev/wp-includes/classes.php on line 560

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl($output) in /home/bombmin/bombinator.com/gamedev/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl($output) in /home/bombmin/bombinator.com/gamedev/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el($output) in /home/bombmin/bombinator.com/gamedev/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el($output) in /home/bombmin/bombinator.com/gamedev/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el($output) in /home/bombmin/bombinator.com/gamedev/wp-includes/classes.php on line 684

Deprecated: Assigning the return value of new by reference is deprecated in /home/bombmin/bombinator.com/gamedev/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/bombmin/bombinator.com/gamedev/wp-includes/theme.php on line 540

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method GoogleSitemapGeneratorLoader::Enable() should not be called statically in /home/bombmin/bombinator.com/gamedev/wp-includes/plugin.php on line 164
Bombinator Game Development » Tricks

Archive for the ‘Tricks’ Category

Idiomatic C/C++: Avoiding Assignment Vs. Equality Errors

Thursday, October 25th, 2007

This is a bit of idiomatic c/c++, that is to say that this isn’t part of any standard, it is just “the way things are done” in c/c++. Ever made an error in a conditional using the assignment operator (=) instead of the equality operator (==)? I know I have, but not so much anymore. The trick is that when you are comparing a variable to a constant to put the constant first. This way if you mess up you will get a compiler error stating that you can’t assign to a constant. This is much preferable to a potentially subtle bug that will no doubt bite you when a deadline is looming. So instead of:

int x;
if( x == 5)
    ; //Do something

do:

int x;
if( 5 == x)
    ;//Do something

Speed Up Your Compilation Times

Tuesday, October 23rd, 2007

For those who may have missed a couple of these, here is an index to the Speed Up Your Compilation Times series:

Speed Up Your Compilation Times Part One: A Trick

Sunday, October 21st, 2007

Here’s a neat little trick that I’m not sure where I picked up. If you have to rebuild an entire project and it is fairly large give this a shot. Create one implementation file (.cpp) that includes all the other implementation files in the project like so:

#include "implementation_file1.cpp"
#include "implementation_file2.cpp"
...
#include "implementation_fileN.cpp"

And compile that file. This forces the entire project into one compilation unit and usually results in a fairly significant drop in compilation times (at least with gcc/g++). Be aware however that when a just a few files have changed then doing a partial rebuild with a build management tool like make is still faster. Though if you are doing a full rebuild then this trick is much faster.