C++ › Preprocessor & Macros

What are predefined macros like __LINE__ and __FILE__?

Beginner

Answer

The preprocessor provides built-in macros: __LINE__ (current line number), __FILE__ (source file name), __DATE__/__TIME__ (build date/time), __func__ (function name), and __cplusplus (the C++ standard version). They're commonly used in logging, assertions, and diagnostics to report where events occurred.
std::cout << __FILE__ << ":" << __LINE__ << "\n";
Real-world example A logging macro embeds __FILE__ and __LINE__ so each message shows where it was emitted.

Common follow-ups: What does __cplusplus indicate? | Where are these used?