Is va_list incompatible between C and C++?
<p>I'm using a library (GNU MicroHttpDaemon) which passes out error messages through a callback which takes a va_list. I pass in a function pointer and if an error occurs then my function is called with a va_list and some other parameters. My problem is that when I receive the va_list it is garbage and attempting to use it causes an exception to be thrown.
I am using Visual Studio 2015 on Windows 10. MicroHttpDaemon was built with the same compiler. My best guess for the cause is that MicroHttpDaemon is written in C, but I am using C++. Can anyone confirm that this is the issue? If it is then is there anything I can do to get the arguments into my C++ code?
My callback is below in case it's any use. Note that it is a static method, so should in general be fine to use as a C callback I think.</p>

<pre><code>void HttpDaemon::parseMessageVa(void * arg, const char * fmt, va_list &amp;ap)
{
    HttpDaemon *daemon = static_cast&lt;HttpDaemon*&gt; (arg);
    size_t n = vsnprintf(nullptr, 0, fmt, ap);
    char *buffer = nullptr;
    try
    {
        buffer = new char[n + 1];
        vsprintf(buffer, fmt, ap);
        try
        {
            daemon-&gt;m_lastMessage = std::string(buffer);
        }
        catch (...)
        {
            delete[] buffer;
            throw;
        }
    }
    catch (...)
    {
        //buffer allocation failed
        daemon-&gt;m_lastMessage = "Memory allocation failure.";
    }
    if(buffer)
        delete[] buffer;
}
</code></pre>