I'm now using the debug {...} I discovered above, which make clear to your compiler that it can leave out all that is in there. If you place your entire debug calls in there it should optimize them out, in any case, it won't call them.JoeKayzA wrote:A bit OT, just out of interest: Do you know whether there is a good or common solution against this problem?Solar wrote: This can get really nasty when you're applying this to C++ code, where converting a complex object to string (to satisfy operator<<() ) can get really expensive.
cheers Joe
If you want a generic solution, gcc supports an attribute called pure which marks a function as one that you can call less than the indicated amount of times without any side effects. Converting an object to a temporary string representation is one of them (at least, I think). You need to watch out with it however, since it'll cause less exceptions etc. too, in the worst case none where you should've been getting one.