Sunday, September 18, 2011

A brief review of my remote development woes

I decided a while back I wanted to do remote C++ development. That is, do all the development on one machine (preferably in a nice IDE), and all the building/running/debugging on another machine. I found three options:

 Eclipse CDT is supposed to support this
 ... with something called RSE. But as documentation is confusing at best, and everything about it is unintuitive, it's very hard to set up. After a long while of trying to make sense of it all, I barely got it working. And then it all crashed every 5 minutes.


NetBeans supports this natively
Netbeans is by far the best option I've found. Set-up is a breeze, everything is seamless and works really well. The only drawback is that Netbeans has a very slow C++ parser which makes it quite painful to work with. So I imagine that the same set-up for java development would be nothing but joy.


Code::Blocks supports this through a third party application called Uniwin
It isn't tremendously hard to set up, but as far as development environments go, C::B feels amateurish and dated.


I suppose the conclusion I'm forced to draw is that the world isn't ready for remote C++ development yet, but if you absolutely have to do it, then NetBeans is your best shot.

Netbeans is the best option at this point

Tuesday, September 6, 2011

Preprocesing C with python

Heh, I cooked together a small shellscript that allows you to pre-process C code (technically also C++-code, if you make a minor alteration to the script) with python.

It's set up to echo everything that doesn't begin with "%%", and pass those lines to python.

#!/bin/bash

tmpsource=`mktemp`
cat $1 |
sed 's/^\([^\%]\+[^\\]*\)\\\(.*\)$/\1\\\\\2/g' |
sed 's/^\([^\%]\+.*\)$/print """\1"""/g' |
sed 's/^[\%][\%]\(.*\)$/\1/g' | python - > $tmpsource
shift
gcc -x c $@ $tmpsource
rm $tmpsource


It's used like this:

./cppy.sh sourcefile.c (flags-for-gcc)

For example, the following code prints "Hello World".

#include <stdio.h>

%%print "char* c = \"Hello World\";";

int main(int argc, char* argv[]) {
printf("%s\n", c);
return 0;
}