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

Compiling with stream.h in multiple object files errors

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: 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

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: