Link to home
Start Free TrialLog in
Avatar of arut
arut

asked on

Using _LINE_ and _FILE_ macros

I was trying to compile the following program:

#include <stdio.h>

main()
{

printf("\n This print is from line %d of file %s",_LINE_,_FILE_);

}

I do gcc test.c (name of the program file) and the compiler says that _LINE_ and _FILE_ are undeclared.

Is there a way to make this work or is this compiler dependent?

Regards,
Arut
ASKER CERTIFIED SOLUTION
Avatar of marconovaro
marconovaro

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rajeev_devin
rajeev_devin

Why are you trying to use those macros. What is your purpose...
arut -

marconovaro is right, it is double-underscore for each.  He should get the points...

rajeev -

those macros give the source code filename and the source code line number.  They are ANSI predefined macros and are commonly used to report errors/status when you can't run in a debugger.

i also support macronovaro.. and
just to add to your knowledge ..( pardon me if u already know this)..
__FUNCTION__ gives u function name