Will Perone

Here is where I put all the miscellanous tips that don't warrant making an entire site for.

Tip 1
Visual Studio has this annoying tendancy to step into STL and other core functions when running in debug mode. Here's how to stop it from doing that. There is a file called autoexp.dat which is usually in [Visual Studio Directory]\Common\MSDev98\Bin\ or similar directory. All you need to do is add the following to it: [ExecutionControl]
std::*=NoStepInto
operator new=NoStepInto

Tip 2
Here are some tips to make DOS easier to work with.
1: One of the most useful things from a unix shell that DOS has turned off by default is tab completion, to enable this: run regedit.exe
go to: HKEY_CURRENT_USER\Software\Microsoft\Command Processor
set PathCompletionChar and CompletionChar to 0x9 (this is ascii for tab)
2: Go to the DOS prompt properties and go into Options and enable Quick Edit mode. This will allow you to do normal cut and paste operations.
3: F7 will bring up a command history box in the DOS window
4: You can find tons of DOS utilities at Channel 1 File Library

Tip 3
Almost all developers know they can set breakpoints on code lines in Visual Studio but not many know that it can also break upon evaluating expressions and contents of variables. This is invaluable for times when your memory gets screwed up or variables start getting wierd values out of nowhere. MSDN has a nice tutorial on how to do it here

Tip 4
Sometimes you want to insert a hard breakpoint into your code. Just do this:
__asm int 3;

Tip 5
Here is an example of a workaround for the lack of variable argument macro support in Visual Studio:
#ifdef _DEBUG
#define DEBUGPRINTF(text) printf text
#else
#define DEBUGPRINTF(text)
#endif
This will compile the printf statment to nothing in release mode and to printf in debug mode. Only oddity with this is that you have to put an extra () when you call it like so:
DEBUGPRINTF(("debug location: %i,%i", x, y));
See my Logging/Console Interface for an example of this.

More Visual Studio tips can be found here

Tip 6
Here is a way to obtain a text string denoting your class name:
#include <typeinfo.h>
typeid(class name, or typename, or class).name()
or alternatively to obtain the fully decorated name:
typeid(class name, or typename, or class).raw_name()
This function does not require RTTI to be enabled if it is not done on a dynamic type, so for example you can use this to print out names of instantiated template classes and it will be generated at compile time. See my Uber Singleton for an example usage of this.
Tip 7
By obtaining the modified date of a file you can have a cheap and easy versioning system for files in your game. Here's how to get the date the file was last modified:
#include <sys/types.h>
#include <sys/stat.h>

// returns a string denoting the time and date of the last modification of the file
const char *GetFileModifiedTime(const char *file)
{
   struct _stat buf;
   _stat(file, &buf);	 
   return ctime(&buf.st_mtime);
}
To get the version of the executable you are running, just pass in the first argument to main into the function; it will be the file that is being run. Ex:
int main(int argc, char **argv)
{	
    printf("This program was last compiled on %s", GetFileModifiedTime(argv[0]));
}
No Comments yet, be the first!
<- for private contact