Preprocessor Macro Recursion Problem

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 UTC