Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1184
  • Last Modified:

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
0
arut
Asked:
arut
1 Solution
 
marconovaroCommented:

I think that the correct definition is:

__LINE__
__FILE__

(double underscore)

M
0
 
rajeev_devinCommented:
Why are you trying to use those macros. What is your purpose...
0
 
gj62Commented:
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.

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now