__LINE__ and __FILE__ -- a beginner's question

Conor P. Cahill cpcahil at virtech.UUCP
Fri Oct 13 11:24:01 AEST 1989


In article <6257 at arcturus>, evil at arcturus.UUCP (Wade Guthrie) writes:
> For what purpose are the __LINE__ and __FILE__ macros used?  Are these
> only useful for the writers of code that, in turn, produces compileable
> code, or is there some use for the applications programmer?

I usually use these for debugging messages:

	fprintf(stderr,"%s(%d): message\n", __FILE__,__LINE__);

and for logfile messages of the same format.   Of course, each time
you use __FILE__, you get a separate string added to your data space, so
I would limit this to development code and strip most of it out of 
production code (using #ifdefs of course).

-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.lang.c mailing list