<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">I use python bindings of libclang.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">Source files are correct.
Build works fine.</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"></span><span style="font-size: 12pt;">I
pass compile_commands.json to libclang </span><span style="font-size: 12pt;">parser. </span></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">And I've written this snippet in python :</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div><i>def do_cparse(srcFile : str, index : clang.cindex.Index, compDB : CompilationDatabase, additional_args : list):</i></div>
<div><i> def clean_commandLine(args : list):</i></div>
<div><i> del args[0]</i></div>
<div><i> i = 0</i></div>
<div><i> while i < len(args):</i></div>
<div><i> if args[i] == '-c' or args[i] == '-o':</i></div>
<div><i> del args[i]</i></div>
<div><i> del args[i]</i></div>
<div><i> else:</i></div>
<div><i> i += 1</i></div>
<div><i> return args</i></div>
<div><i> </i></div>
<div><i> if compDB is not None:</i></div>
<div><i> compileCommands = compDB.getCompileCommands(srcFile)</i></div>
<div><i> if compileCommands is None:</i></div>
<div><i> args = []</i></div>
<div><i> else:</i></div>
<div><i> args = compileCommands.__getitem__(0).arguments</i></div>
<div><i> args = [arg for arg in args]</i></div>
<div><i> args = clean_commandLine(args)</i></div>
<div><i> else:</i></div>
<div><i> args = []</i></div>
<div><i> try: </i></div>
<div><i> tu = index.parse(srcFile, args.extend(additional_args))</i></div>
<div><i> except TranslationUnitLoadError:</i></div>
<div><i> pass</i></div>
<div><i> #from pprint import pprint</i></div>
<div><i> #pprint(('nodes', get_info(tu.cursor)))</i></div>
<div><i> </i></div>
<div><i> for diagnostic in tu.diagnostics:</i></div>
<div><i> print(diagnostic.format() + '\n')</i></div>
<br>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">But diagnostics deliver this :</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div><i>/usr/include/limits.h:123:16: fatal error: 'limits.h' file not found</i></div>
<div><i>/usr/include/stdio.h:33:11: fatal error: 'stddef.h' file not found</i></div>
<div><i>/usr/include/stdlib.h:32:10: fatal error: 'stddef.h' file not found</i></div>
<div><i>/usr/include/unistd.h:229:10: fatal error: 'stddef.h' file not found</i></div>
<br>
<p></p>
<p style="margin-top:0;margin-bottom:0">It seems libclang goes wrong. Is it a known issue ?</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">More, project C-headers are also affected while -I<path to myheaders> is passed to Index.parse().</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Thanks a lot for your contributions.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Regards</p>
<p style="margin-top:0;margin-bottom:0">Didier.</p>
</div>
</body>
</html>