I want to add some code before every function call to do some checking. The only way I know is:
#define SOME_CODE printf(\"doing something...\");
class test
A fair number of profilers (and similar tools) can/will do things like this. It's actually easier at the binary level than the source code level. At the source code level, it's sufficiently difficult that for most practical purposes you might as well treat it as impossible.
Depending on the compiler you're using, there's a pretty fair chance that it has a flag to support such insertions -- usually present primarily to support the profilers and such I mentioned above.