Discussion:
[GCC-XML] Setting relative path for included user defined header files in C++ code
Karanbir Singh
2014-09-16 10:10:50 UTC
Permalink
Hello gccxml -mailing-list,
I am trying to parse a C++ file which includes many user defined
header files. GCCXML is not able to read the location of header files
included in the code. Is there a way I can change the base path which
when appended with the path mentioned in "#include <pathname>" lines
written in the code gives the path of the directory containing the
header files.

I tried to work around this problem by specifying the paths of all the
header files in a text file and then using the following command :

--gccxml-gcc-options textfilename

But this creates a problem in case there is a long chain of
dependencies as I would have to specify the paths of files included in
the header files as well. Is there a way to solve this problem?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/gccxml/attachments/20140916/b6d90786/attachment.html>
Brad King
2014-09-16 14:24:25 UTC
Permalink
I am trying to parse a C++ file which includes many user defined header files.
In this regard gccxml is just like a compiler: all include directories
must be specified with -I options just as if you were trying to compile
the source file.

-Brad
Karanbir Singh
2014-09-17 09:56:45 UTC
Permalink
Thanks a lot Brad. I am facing two more issues.
1) gccxml seems to be parsing a lot of code which is not in the current C++
file. I guess it is parsing the included header files. Is there a way to
avoid this?

2) I need to dump the function bodies to xml as well. Does the patch
offered by Daniel J Lauk succesfully dump function bodies to xml?
Post by Karanbir Singh
I am trying to parse a C++ file which includes many user defined header
files.
In this regard gccxml is just like a compiler: all include directories
must be specified with -I options just as if you were trying to compile
the source file.
-Brad
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://public.kitware.com/mailman/listinfo/gccxml
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/gccxml/attachments/20140917/126beb2b/attachment-0001.html>
Brad King
2014-09-18 12:35:35 UTC
Permalink
Post by Karanbir Singh
Thanks a lot Brad. I am facing two more issues.
1) gccxml seems to be parsing a lot of code which is not in
the current C++ file. I guess it is parsing the included
header files. Is there a way to avoid this?
No. The parser *is* a compiler. It needs the full translation
unit just like any other compiler. However, you can use
-fxml-start=some_decl to dump only a subset of the parsed
declarations to xml.
Post by Karanbir Singh
2) I need to dump the function bodies to xml as well.
This is not supported by gccxml.
Post by Karanbir Singh
Does the patch offered by Daniel J Lauk succesfully dump
function bodies to xml?
Perhaps but it has not been maintained with the rest of gccxml
so I do not know if it would still work.

I suggest looking at Clang instead:

http://clang.llvm.org/docs/Tooling.html

-Brad

Loading...