__FILE____FILE____FILE__ is a preprocessor macro that expands to full path to the current file. __FILE__ is useful when generating log statements, error messages intended for programmers, when throwing exceptions, or when writing debugging code. int logError (const char* file, const std::string& message) { cerr << "[" << file << "]" << message << endl; } #define LOG( message ) logError( __FILE__, message ) // LOG can now be used to produce a log message that includes the file in which the log occurrredThe __FILE__ macro is often combined with the __LINE__ macro, which expands to the current line number. Related C preprocessor tutorial |