[petsc-users] Wrapping PetscFPrintf

Dominik Szczerba dominik at itis.ethz.ch
Sat Nov 10 15:38:55 CST 2012


Hi,

I need to have a wrapper to PetscFPrintf and PetscSynchronizedFPrintf.
I am aware of the problems and tried following as described here:

http://c-faq.com/varargs/handoff.html

So I have:

	virtual bool VPrint(const char* format, va_list argp) = 0;
	virtual bool Print(const char* format, ...) = 0;

implemented as:

	bool CXCoreReporting::VPrint(const char* format, va_list argp)
	{
		vfprintf(stderr, format, argp);
		return true;
	}

	bool CXCoreReporting::Print(const char* format, ...)
	{
		va_list argp;
		va_start(argp, format);
		VPrint(format, argp);
		va_end(argp);
		return true;
	}


Now the problem is that it just does not work... I still get trash
when calling e.g. Print("%d", i).
Does anyone see a way out?

Many thanks
Dominik


More information about the petsc-users mailing list