News for hackers. Stuff that matters.
Re:The Preprocessor Iceberg Meme by zabzonk on Thursday July 14, 2022 @08:35AM (#32095206)
I started but couldn't finish. For example __FILE__ (and __LINE__ and similar) certainly can be used in user-written macros, but they evaluate to the file/line they appear at in the macro source, not at the line the macro is invoked.
Re:The Preprocessor Iceberg Meme by elteto on Thursday July 14, 2022 @08:40AM (#32095269)
This is not correct. They evaluate at the point where they are expanded.

I’ve used them countless of times to implement “log” and “trace” macros that show file/line.

Re:The Preprocessor Iceberg Meme by zabzonk on Thursday July 14, 2022 @08:43AM (#32095309)
I have used them countless timers myself, but not within another macro

Edit: Sorry I am on multiple drugs at the moment for a severe fracture - I'm a bit confused, nurse has just been. I will shut up now.

To prove I am not completely out of it (though wrong), here's one I wrote a lot earlier: https://latedev.wordpress.com/2012/08/09/c-debug-macros/

Re:The Preprocessor Iceberg Meme by elteto on Thursday July 14, 2022 @09:39AM (#32095956)
Sorry to hear that! Rest up and don’t worry about cpp macros for now ;) they’ll still be there after you heal. Good luck!
Re:The Preprocessor Iceberg Meme by seoaeu on Thursday July 14, 2022 @09:13PM (#32103456)
Honestly, I suspect that cpp macros will outlive us all
Re:The Preprocessor Iceberg Meme by gpderetta on Thursday July 14, 2022 @08:49AM (#32095370)
most commonly they are typically used in the definition of the assert macro. For example: https://github.com/lattera/glibc/blob/master/assert/assert.h .
Re:The Preprocessor Iceberg Meme by camel-cdr on Thursday July 14, 2022 @08:41AM (#32095285)
> they evaluate to the file/line they appear at in the macro source, not at the line the macro is invoked.

What are you talking about? Maybe I'm missing your point, but:

#define A __LINE__

A

A

Expands to:

2

3