LuckyLucks used Ask the Experts™

__FILE__ and __LINE__ are in which C++ header that I need to include in order to use them?

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
evilrixSenior Software Engineer (Avast)
They are not defined in any header, you just use them.
Top Expert 2016
to add to above comment:

the macros __FILE__ and __LINE__ were provided by the precompiler and expand to the current source file name and line number.

for vc compiler you may see more at https://msdn.microsoft.com/en-us/library/b0084kay.aspx

__FILE__ and __LINE__ could be used for some error message to report some dissent detected by the program. For example,

 std::cerr << "Internal error: negative string length " << len << " at " << __FILE__ << ", line " << __LINE__ "\n";

Open in new window

evilrixSenior Software Engineer (Avast)

LuckyLucks, you realise that my comment, the first one posted, actually answered your question, right? At best, Sara has just provided additional information to support my answer.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial