Re: [Anjuta-list] suggestion
- From: Biswapesh Chattopadhyay <biswapesh_chatterjee tcscal co in>
- To: anjuta-list lists sourceforge net
- Subject: Re: [Anjuta-list] suggestion
- Date: Sun Sep 9 22:41:02 2001
On Friday 07 September 2001 09:54 pm, Naba Kumar wrote:
> On 08 Sep 2001 17:23:16 +0530, Biswapesh Chattopadhyay wrote:
> > OK - I figured out a way to do this without touching the code. Do this:
> > [...]
>
> Thanks. That's really nice. I had the idea of implementing this
> dynamically, but somehow I could not figure out how to scan for the
> included files in a given source file. If somebody could provide a code
> segment that can parse a file for "local" includes, that would really be
> very helpful.
This works from command line (gives all include file names) :
cpp <FileName> | grep "^#" | awk '{print $3}' | sed 's/"//g' | sort -u
Alternatively, try this:
cpp -H <FileName> | grep "^\." | awk '{print $2}' | sort -u
If you do not want the system headers, you need cpp -nostdinc and -nostdinc++
(see the cpp manual for details). You also might want to try -MG to ignore
missing header files or -MF with -M to get just a list of dependencies
(including header file). For example, cpp <FileName> -MF <SomeFile> -M will
give you a list of all dependent files (including all headers - actually they
*will* be headers, unless you include "C" files) in <SomeFile>. This might be
useful for automatic makefile generation as well.
Of course, cpp will also give you the actual prototypes, so maybe you can
just grab those directly instead of running ctags on the files.
Personally, I feel that the C pre-processor is the best thing to use in these
cases since it is sure to work in the same way as the compiler, accepts the
standard flags (such as -I for includes, etc.) and is the most powerful.
YMMV, though. Also, AFAIK, there is no C API for interacting with the C
pre-processor (at least not a standardized one, there might be a GCC specific
one that I'm not aware of).
Hope this helps.
Biswa.
>
> --
>
> Regards,
> -Naba
>
> -------------------------------------------------------------
> critic, n.:
> A person who boasts himself hard to please because nobody tries
> to please him.
> -- Ambrose Bierce, "The Devil's Dictionary"
> -------------------------------------------------------------
>
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
--
- Biswapesh.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]