Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-82

Compiling with stream.h in multiple object files errors

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.10.0
    • 0.10.0
    • None
    • None
    • Windows XP, Visual Studio 2005, CVS build 11am 12th May 2003

    Description

      Using the stream.h in a project with more than one object file (i.e. two classes both using the stream logger) causes an error at link time:

      File2.obj : error LNK2005: "class log4cxx::logstream & _cdecl operator<<(class log4cxx::logstream &,class std::ios_base & (_cdecl*)(class std::ios_base &))" (??6@YAAAVlogstream@log4cxx@@AAV01@P6AAAVios_base@std@@AAV23@@Z@Z) already defined in File1.obj

      Should the stream.h << operators be inline functions? This allows it to compile, but unsure if this is a true fix?

      E.g.

      ::log4cxx::logstream& operator<<(
      ::log4cxx::logstream& lhs,
      const ::log4cxx::LevelPtr& rhs) {
      lhs.setLevel(rhs);
      return lhs;
      }

      changes to

      inline ::log4cxx::logstream& operator<<(
      ::log4cxx::logstream& lhs,
      const ::log4cxx::LevelPtr& rhs) {
      lhs.setLevel(rhs);
      return lhs;
      }

      Chris

      Attachments

        Activity

          People

            carnold@apache.org Curt Arnold
            obe1line Chris Storah
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: