[net.lang.c] "__LINE__ and __FILE__

dap1@ihlpf.UUCP (11/02/83)

#N:ihlpf:18400004:  0:395
ihlpf!dap1    Nov  1 16:25:00 1983

I just found that __LINE__ and __FILE__ contain the line number and file
currently being executed.  Since they don't need to be declared, they must
be evaluated by the compiler (along the lines of sizeof()).  Is this a
standard feature of C and if not, how widespread is it?

                                                 Darrell Plank
                                                 BTL-IH

guy@rlgvax.UUCP (Guy Harris) (11/02/83)

__LINE__ and __FILE__ are evaluated by the pre-processor (they contain the
name of the source line and file, and not the line number of the file
actually handed to the compiler, so the pre-processor knows enough to give
them values).  They were stuck into the pre-processor when it was rewritten
(with a significant speedup) by John Reiser, and have been in every version
of the preprocessor since V7.  They are not documented, however, until System
V.  I'd use them anyway, although some compilers may not use the Bell
preprocessor and may not have implemented them; if they don't implement them,
they're going to have trouble with a lot of code (including the "assert"
macro) so they should implement them.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy

swatt@ittvax.UUCP (Alan S. Watt) (11/03/83)

Just a note about these guys:

  In UTS, the names are "_FILENM" and "_LINENO" respectively.
Don't ask me why they had to go and change them.  This raises the
possiblity that other vendor-supplied C preprocessors have also
been changed.

	- Alan S. Watt

guy@rlgvax.UUCP (Guy Harris) (11/07/83)

Boy, is Amdahl gonna be surprised when they read the System V manual!  It
*documents* __LINE__ and __FILE__ (as well as defined())!  If they intend
to be S5 compatible, and they *had* to change __LINE__ and __FILE__, they're
gonna be in a world of hurt...

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy