re: Help fix my bloated C++ macros! VIEW POST

FULL DISCUSSION
 

The first thing I usually do is try to directly convert the macro to a proper function without changing the name and then test. If there's a nested macro in there, convert it (if needed) and then test. This is so you won't have to deal with the calling functions until you're done with the conversion.

When you're done you can just rename the function and all the callers to whatever you want it to be.

Regarding the speed and code size, you can try to inline the new functions to see how much difference it makes.

 

I've pushed a lot into functions already. I need to get the calling location though, so I have to get access to LINE and FILE somehow. That, along with the other boilerplate I don't really want to repeat.

The conditional expansion of the logged values is an essential must as well. The rules on eliminating expressions are simply not good enough that I'll avoid the expensive creation (the optimizer just won't know there are no side-effects in the called function unfortunately).

code of conduct - report abuse