Wednesday, June 1, 2011

Linking MingW32 with psapi

Here's something I came across that didn't have a good answer when I googled. If you get link errors with MingW32 like:

undefined reference to `GetProcessMemoryInfo@12' or
c:/justinhj/mem.cpp:55: undefined reference to `EnumProcesses@12'

Then you are not linking with the library psapi, and you need it.

To do this just add -lpsapi to your command line. It needs to be last in the list of libraries too!

Source from http://justinsboringpage.blogspot.com/2009/05/linking-mingw32-with-psapi.html

With Eclipse Helios: you add by going to Project > Properties > C/C++ Build > Settings > MinGW C Linker > Libraries, add psapi to it.

Thursday, January 27, 2011

String to Number AS2



function stringToNum(dec_input:String)
{
var sum:Number = 0;
var dec_length:Number = dec_input.length;
var expCnt:Number = dec_length - 1;
for (var i = 0; i <= dec_length-1; i++) {
var dec_value:Number = (dec_input.charCodeAt(i) - 48);
dec_value *= (Math.pow(10, expCnt));
sum += dec_value;
expCnt -= 1;
}
return sum;
}