mercredi 6 avril 2022

ostringstream error with log4cxx and c++11

I'm using log4cxx 0.10.0 and I have a problem compiling my software. I created a test program:

#include <sstream>
#include <log4cxx/logger.h>

using namespace log4cxx;
using namespace log4cxx::helpers;

LoggerPtr loggerMyMain(Logger::getLogger( "main"));

int main() {
    std::ostringstream s;
    s << "Test";
    LOG4CXX_DEBUG(loggerMyMain, "aaa" << s);

    return 0;
}

and I receive error from gcc:

/usr/include/log4cxx/helpers/messagebuffer.h: In instantiation of 'std::basic_ostream& log4cxx::helpers::operator<<(log4cxx::helpers::CharMessageBuffer&, const V&) [with V = std::__cxx11::basic_ostringstream]': ../main.cpp:23:5: required from here /usr/include/log4cxx/helpers/messagebuffer.h:190:44: error: no match for 'operator<<' (operand types are 'std::basic_ostream' and 'const std::__cxx11::basic_ostringstream') return ((std::basic_ostream&) os) << val; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~

Using C++03 standard the error is no more present. I'm using GCC 8.3.1.

Aucun commentaire:

Enregistrer un commentaire