Log4cxx
  1. Log4cxx
  2. LOGCXX-82

Compiling with stream.h in multiple object files errors

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.10.0
    • Fix Version/s: 0.10.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      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

        Activity

        Chris Storah created issue -
        Curt Arnold made changes -
        Field Original Value New Value
        Fix Version/s 0.10.0 [ 10782 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Curt Arnold
            Reporter:
            Chris Storah
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development