3 ms·
If it's a macro, then the preprocessor expands the macro at the callsite (which then expands the __FILE__ and __LINE__ macros in that location). If you use a f
by CuriousCosmic 3y ago
If it's a macro, then the preprocessor expands the macro at the callsite (which then expands the __FILE__ and __LINE__ macros in that location).
If you use a function, then the __FILE__ and __LINE__ expand inside that function and point to the location inside the function rather than the callsite of the function.
- codr7 3y agoWhich is why you trampoline the function call through a macro to get the expansion, the logging logic can still be inside the function.
- CuriousCosmic 3y agoI agree and that's how I've always handled it. But the OP is trying to solve this purely without macros which is why it is an issue.