lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev cpp portabliity question


From: Vlad Harchev
Subject: Re: lynx-dev cpp portabliity question
Date: Fri, 15 Oct 1999 21:13:54 +0500 (SAMST)

On Fri, 15 Oct 1999, Larry W. Virden wrote:

> Re: expanding macro symbols
> 
> I believe that with the ANSI c compiler, the macro preprocessor was specified
> to not do the recursive expansion.
> 
> On the Sun C compiler, the example expans the return x into return x+x ...

 Sunc C and gcc are correct. Here is a quote from the Draft2 for language
C++ (dated Nov 96) regarding this topic (16.3.4 [cpp.rescan], paragraph 2):

2 If the name of the macro being replaced is found during this  scan  of
  the replacement list (not including the rest of the source file's pre-
  processing tokens), it  is  not  replaced.   Further,  if  any  nested
  replacements encounter the name of the macro being replaced, it is not
  replaced.  These nonreplaced macro name preprocessing  tokens  are  no
  longer  available  for  further  replacement  even  if  they are later
  (re)examined in contexts in which that macro name preprocessing  token
  would otherwise have been replaced.

So, infinite loop is incorrect behaviour. But tokens other than the name of
macro being expanded are subject to recursive macro expansions. And as I
remember or believe, nothing differs in preprocessor description in either old
C++, new C++ and plain C.
 
> -- 
> Larry W. Virden                 <URL: mailto:address@hidden>
> <URL: http://www.purl.org/NET/lvirden/> <*> O- Save us from the snobs.
> Unless explicitly stated to the contrary, nothing in this posting should 
> be construed as representing my employer's opinions.
> -><-
> 

 Best regards,
  -Vlad


reply via email to

[Prev in Thread] Current Thread [Next in Thread]