W3C home > Mailing lists > Public > www-lib@w3.org > April to June 1999

Preprocessor Macro Recursion Problem

From: Michael Saunders <michael@amtec.com>
Date: Tue, 08 Jun 1999 10:08:29 -0700
Message-ID: <375D4E0D.201C09A7@amtec.com>
To: www-lib@w3.org
Version 5.2.8 of "modules/expat/xmlparse/xmlparse.c" does not compile on the SGI
6.2 because of a structure member named "encoding" having the same name as a
macro that expands to the structure member. I examined the output from the
preprocessor and it was apparent that it was recursively replacing the member
"encoding". I was able to fix the problem by changing the name of the structure
member name and it's counterpart in the "encoding" macro of the original file:

Here are the diffs that of the file "xmlparse.c":

diff xmlparse_v5.2.8.c xmlparse.c
225c225
<   const ENCODING *encoding;
---
>   const ENCODING *encodingMEMBER;
269c269
< #define encoding (((Parser *)parser)->encoding)
---
> #define encoding (((Parser *)parser)->encodingMEMBER)


Since the macro is always used to access the structure member the changes to the
file were small. I cannot explain why this problem does not surface with the
other members of the structure but it simply does not.

This may be a bug with the preprocessor more than it is with libwww, however if
macros are to be used to access the structure members then it seems like it
would be a good idea to put underscores in front or behind the member names to
distinguish them from the macro accessors.

Michael
Received on Tuesday, 8 June 1999 13:08:44 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:29 GMT