Menu

support for std::string....help please

Help
mantra
2006-04-06
2013-05-20
  • mantra

    mantra - 2006-04-06

    std::sting abc = "abc";

    CategoryStream & logger = Category::getInstance("Main");

    logger.infoStream << abc;

    I am getting the following error, when compiling my code.

    "Main.cpp", line 129: Error: The operation "log4cpp::CategoryStream << std::basic_string<char, std::char_traits<char>, std::allocator<char>>" is illegal.

     
    • gwk

      gwk - 2006-06-07

      You can try:

      logger.inforStream <<abc.c_str();

      which should fix the problem you are having, since it converts the string object into a character array.

       
    • Philippe Haution

      You told neither the version of log4cpp you are using nor your platform and compiler.

      What you are trying to do should work since CategoryStream has an operator<< taking a const std::string& as argument.

      PS :
      I guess you meant :
      Category& logger = Category::getInstance("Main");
      logger.infoStream() << abc;

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.