Thought I'd offer this tip for Java users.
As you know Java doesn't support conditional defines, so I use comments:
//[IFDEF:SMARTINSPECT]import SmartInspect
//[IFDEF:SMARTINSPECT]SmartInspect.logMessage("blah")
Note that the "[IFDEF:SMARTINSPECT]" is meaningless and you can use any string here, this just helps make it self explanatory.
And in an Ant build target I use a section like this:
<copy todir="${debug-src-dir}">
<fileset dir="${src-dir}">
<include name="**/*.java"/>
</fileset>
<filterset begintoken="//[IFDEF:" endtoken="]">
<filter token="SMARTINSPECT" value=""/>
</filterset>
</copy>
This copies all the source to a separate directory while stripping "//[IFDEF:SMARTINSPECT]" and leaving the remainder of the line. Then that directory gets compiled into a debug version of the application.
Doing it this way means we don't have to ship SmartInspect.jar with the normal version of our app.
Hope this may help someone!
cheers,
Daniel