<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 23 Jul 2016, at 21:59, Matt <<a href="mailto:mattator@gmail.com" class="">mattator@gmail.com</a>> wrote:</div><div class=""><div class=""><br class="">I want the C function but pygccxml throws a<br class="">"pygccxml.declarations.scopedef.multiple_declarations_found_t"<br class="">exception because it considers the C++ code I think. In C there should<br class="">be only one result since C doesn't accept overloads.</div></div></blockquote><div><br class=""></div><div>One may need to double-check the xml file that is generated.</div><div>The keep_xml flag can be used to keep the xml file, and pygccxml.utils.loggers.set_level(logging.DEBUG) can</div><div><span class="">be used to find out where the xml file is written (if you are not </span>specifying the path manually).</div><div><br class=""></div><div>I am not sure there is any test for what you want to achieve. Maybe we should</div><div>first write a minimal c++/c code example, demonstrating the problem.</div><div>There is a test called “unittests/plain_c_tester.py”, which is probably the only C-things</div><div>pygccxml supports.</div><div><br class=""></div><div>There is a note under version 1.1.0 that handling of “C” functions was added.</div><div><br class=""></div><div>I do not know of all the internals of pygccxml, as I did not write that tool</div><div>initially. We may need to explore the code to try to solve your problem.</div><div>Also, as we switched from gccxml to castxml, specific things like this</div><div>may not work out of the box or need further testing.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="">Right now, I search for it with "decl =<br class="">global_namespace.free_function(name=row["name"]) " . How can I tell<br class="">pygccxml that I look only for the C versions ?<br class=""></div></div></blockquote><div><br class=""></div><div>As said before, I have the feeling that the code in “unittests/plain_c_tester.py”</div><div>is showing what can be done with C functions. If we want to do more,</div><div>we may need to write more code to support that. But there may be already</div><div>some “hidden” features I am not aware of.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="">Also, in most projects I know examples are in a top level directory or<br class="">in the source so it's easy to find & use them. In pygccxml they are in<br class="">the doc subfolders thus I wonder if it were doable to move them there<br class="">?<br class=""></div></div></blockquote><div><br class=""></div><div>Never thought of that. I will try to move them, but I need to tweak the</div><div>tests that make sure that the examples are working.</div><div>Also, some lines in the examples are only there to be able to run</div><div>the tests on them; these lines are removed for the much cleaner output</div><div>on the documentation webpage: <a href="http://pygccxml.readthedocs.io/en/develop/examples.html" class="">http://pygccxml.readthedocs.io/en/develop/examples.html</a></div><div><br class=""></div><div>Cheers</div><div><br class=""></div><div>Michka</div><div><br class=""></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div class=""><br class="">2016-07-22 16:21 GMT+02:00 Michka Popoff <<a href="mailto:michkapopoff@gmail.com" class="">michkapopoff@gmail.com</a>>:<br class=""><blockquote type="cite" class="">Hi<br class=""><br class="">thanks for the nice comments.<br class=""><br class="">Using print on declarations in pygccxml is a nice way to debug you code,<br class="">but often you may not want to rely on the __str__ implementation in you real code.<br class=""><br class="">The output of the __str__ method may vary depending on you compiler / platform / code,<br class="">and I can not guarantee that this will work in a reliable way in all the situations.<br class="">This is something I may add to the documentation; __str__ is for debugging<br class="">purposes only.<br class=""><br class="">It is probably better to build the string you want by using the .name, .return_type,<br class="">.arguments ... attributes. This is often more flexible, and also more performant,<br class="">as you select only the things that you are interested in.<br class=""><br class="">Cheers<br class=""><br class="">Michka<br class=""><br class=""><br class=""><blockquote type="cite" class="">On 22 Jul 2016, at 16:10, Matt <<a href="mailto:mattator@gmail.com" class="">mattator@gmail.com</a>> wrote:<br class=""><br class="">I found the code in declarations/free_calldef.py and hacked it<br class="">locally, I might copy/paste the code in my script later then.<br class=""><br class="">Sorry for the noise<br class=""><br class="">2016-07-22 15:36 GMT+02:00 Matt <<a href="mailto:mattator@gmail.com" class="">mattator@gmail.com</a>>:<br class=""><blockquote type="cite" class="">Hi,<br class=""><br class="">I've just started with pygccxml/castxml and I must admit it's quite<br class="">impressive: doc/examples and worked straightout of the box.<br class=""><br class="">I want to use pygccxml to generate wrapper functions around glibc<br class="">functions. I can't use LD_PRELOAD or --wrap techniques so I have to<br class="">copy/paste the declarations of these functions which is a pain.<br class="">I am trying to automate this copy/paste via pygccxml.<br class=""><br class="">So far, I have:<br class="">==<br class="">func1a = global_namespace.free_function(name="printf")<br class="">print(func1a)<br class="">==<br class="">which output:<br class="">extern int printf(__restrict__ char const * __format, ...) [free function]<br class="">is very near to what I want:<br class="">extern int printf(__restrict__ char const * __format, ...)<br class=""><br class="">I have done dir(func1a) to see which members I could use and grepped<br class="">for __str__ to see the magic but miserably fail to find the location.<br class="">How could I output the same declaration as in the header please ?<br class=""><br class=""><br class="">Cheers<br class=""><br class="">Nb: In the list of  programs using pygccxml you could add <a href="http://www.nsnam.org" class="">www.nsnam.org</a><br class=""></blockquote>_______________________________________________<br class="">CastXML mailing list<br class=""><a href="mailto:CastXML@public.kitware.com" class="">CastXML@public.kitware.com</a><br class="">http://public.kitware.com/mailman/listinfo/castxml<br class=""></blockquote><br class=""></blockquote></div></div></blockquote></div><br class=""></body></html>