Not possible with compiled languages. You can compile new functions with the compiler, but you can't link them into the existing binary. Go with dlls or a build a bridge for one of the scripting languages out there.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com