preprocessor question (non-ANSI)

Richard O'Keefe ok at cs.mu.oz.au
Tue Oct 10 22:46:30 AEST 1989


In article <174 at eliza.edvvie.at>, johnny at edvvie (Johann Schweigl) writes:
: How can I replace a text token by itself, along with some additional text?
: Example: 
: EXEC SQL select * from emp;     __curline = 23; EXEC SQL select * from emp;
: before ^^^^^^^^^^^^^^^^^^^^     after ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: 
: #define EXEC __curline = __LINE__; EXEC 
: is not the solution, cpp would try to resolve EXEC recursively

Well, according to gcc, it _is_ the solution.  When I do
	% cat >zabbo.c <<end_of_file.
	#define EXEC __curline = __LINE__; EXEC
	EXEC SQL select * from exp;
	end_of_file.
	% gcc -ansi -pedantic -E zabbo.c
I get the output
	__curline = 2; EXEC  SQL select * from emp;
My understanding is that ANSI macro expansion explicitly checks for
recursion and blocks it, but my draft is over a year out of date and
in another country, so I'll just say "works in gcc".



More information about the Comp.lang.c mailing list