This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: semantic of used_define cpp callback?
- From: Tom Tromey <tromey at redhat dot com>
- To: Arnaud Charlet <charlet at adacore dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Sun, 15 Nov 2009 10:18:19 -0700
- Subject: Re: semantic of used_define cpp callback?
- References: <20091115111315.GA77473@adacore.com>
- Reply-to: Tom Tromey <tromey at redhat dot com>
>>>>> "Arnaud" == Arnaud Charlet <charlet@adacore.com> writes:
Arnaud> /* Callbacks for when a macro is expanded, or tested (whether
Arnaud> defined or not at the time) in #ifdef, #ifndef or "defined". */
Arnaud> void (*used_define) (cpp_reader *, unsigned int, cpp_hashnode *);
Arnaud> Is the intent that used_define should only be called when used
Arnaud> in an #ifdef as explained by the documented, or also when
Arnaud> expanded in the source code?
I don't know the intent aside from what is in the comment.
However, it looks like this is used to implement -dU:
`U'
Like `D' except that only macros that are expanded, or whose
definedness is tested in preprocessor directives, are output;
the output is delayed until the use or test of the macro; and
`#undef' directives are also output for macros tested but
undefined at the time.
I suppose the idea is to emit each used macro a single time only, the
code seems to confirm this.
Arnaud> If the above is correct, what I'm interested in is a callback
Arnaud> that will be called each time a macro is expanded or tested
Arnaud> *anywhere* in the source code (for the purpose of generating
Arnaud> cross-reference info for macros), so would the addition of a new
Arnaud> callback (e.g.
Arnaud> void (*used) (cpp_reader *, unsigned int, cpp_hashnode *);
Arnaud> ) be acceptable in principle? If so, I'll post a formal patch on
Arnaud> gcc-patches@
Yes, this would be fine.
Tom