Friday, July 26, 2013

C++ on Unix

Build

AIX
/usr/vacpp/bin/xlC_r -o mybinary.exe mysource.cpp

SOLARIS
/isv/sw6.0_u2p/SUNWspro/bin/CC -o mybinary.exe mysource.cpp

HP-UX
/opt/aCC/bin/aCC -AA -o mybinary.exe mysource.cpp

LINUX
g++ mysource.cpp -o mybinary.exe

Debug

valgrind is supposed to be great, but requires a debug build

/usr/bin/valgrind

For quick and dirty outputs:

#include <stdio.h>
#define DUMP(msg) { FILE *fp; fp=fopen("/tmp/dump.txt","a"); fwrite(msg,sizeof(char),sizeof(msg),fp); fwrite("\n",sizeof(char),1,fp); fclose(fp); }
#define DUMP2N(msg,n1,n2) { FILE *fp; fp=fopen("/tmp/dump.txt","a"); char buffer[300]; int num = sprintf(buffer,msg,n1,n2); fwrite(buffer,sizeof(char),num,fp); fwrite("\n",sizeof(char),1,fp); fclose(fp); }
{ "loggedin": false, "owner": false, "avatar": "", "render": "nothing", "trackingID": "UA-36983794-1", "description": "", "page": { "blogIds": [ 434 ] }, "domain": "holtstrom.com", "base": "\/michael", "url": "https:\/\/holtstrom.com\/michael\/", "frameworkFiles": "https:\/\/holtstrom.com\/michael\/_framework\/_files.4\/", "commonFiles": "https:\/\/holtstrom.com\/michael\/_common\/_files.3\/", "mediaFiles": "https:\/\/holtstrom.com\/michael\/media\/_files.3\/", "tmdbUrl": "http:\/\/www.themoviedb.org\/", "tmdbPoster": "http:\/\/image.tmdb.org\/t\/p\/w342" }