If you are getting garbage, run in valgrind and/or a debugger. Also make sure the int sizes are converted correctly as for a direct call to printf.<div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Nov 10, 2012 at 3:38 PM, Dominik Szczerba <span dir="ltr"><<a href="mailto:dominik@itis.ethz.ch" target="_blank">dominik@itis.ethz.ch</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I need to have a wrapper to PetscFPrintf and PetscSynchronizedFPrintf.<br>
I am aware of the problems and tried following as described here:<br>
<br>
<a href="http://c-faq.com/varargs/handoff.html" target="_blank">http://c-faq.com/varargs/handoff.html</a><br>
<br>
So I have:<br>
<br>
        virtual bool VPrint(const char* format, va_list argp) = 0;<br>
        virtual bool Print(const char* format, ...) = 0;<br>
<br>
implemented as:<br>
<br>
        bool CXCoreReporting::VPrint(const char* format, va_list argp)<br>
        {<br>
                vfprintf(stderr, format, argp);<br>
                return true;<br>
        }<br>
<br>
        bool CXCoreReporting::Print(const char* format, ...)<br>
        {<br>
                va_list argp;<br>
                va_start(argp, format);<br>
                VPrint(format, argp);<br>
                va_end(argp);<br>
                return true;<br>
        }<br>
<br>
<br>
Now the problem is that it just does not work... I still get trash<br>
when calling e.g. Print("%d", i).<br>
Does anyone see a way out?<br>
<br>
Many thanks<br>
<span class="HOEnZb"><font color="#888888">Dominik<br>
</font></span></blockquote></div><br></div>