[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Problems building
From:       Albert Chin <kde-devel () mlists ! thewrittenword ! com>
Date:       2004-12-04 17:01:21
Message-ID: 20041204170121.GB56166 () mail1 ! thewrittenword ! com
[Download RAW message or body]

On Sat, Dec 04, 2004 at 12:11:29PM -0200, Thiago Macieira wrote:
> Albert Chin wrote:
> >> Or, then, it's because of the anonymous namespace that encloses the
> >> whole file. Try moving the ending brace for that namespace (last thing
> >> in the file) to before the KResolverThread::KResolverThread
> >> implementation.
> >
> >Thanks. I removed the anonymous namespace code and it compiles now:
> 
> Can you try without removing the anonymous namespace? I.e., restrict it to 
> the new class in the file.

This works:
--- kresolvermanager.cpp.orig	Fri Dec  3 17:20:29 2004
+++ kresolvermanager.cpp	Sat Dec  4 10:54:07 2004
@@ -208,6 +209,8 @@
 
 static pid_t pid;		// FIXME -- disable when everything is ok
 
+}
+
 KResolverThread::KResolverThread()
   : data(0L)
 {
@@ -767,5 +770,3 @@
   QMutexLocker locker(&mutex);
   dequeueNew(obj);
 }
-
-} // anonymous namespace

What is the preferred solution?

BTW, I also had a problem building kdecore/network/ksocketdevice.cpp.
The IRIX C++ error was:
cc-1553 CC: ERROR File = ksocketdevice.cpp, Line = 813
  The overloaded function "KNetwork::KSocketDevice::createDefault" cannot be
          defined in the current scope.

    KSocketDevice* KSocketDevice::createDefault(KSocketBase* parent)
                   ^

cc-1553 CC: ERROR File = ksocketdevice.cpp, Line = 828
  The overloaded function "KNetwork::KSocketDevice::createDefault" cannot be
          defined in the current scope.

    KSocketDevice* KSocketDevice::createDefault(KSocketBase* parent, int capabilities)
                   ^

cc-1553 CC: ERROR File = ksocketdevice.cpp, Line = 845
  The function "KNetwork::KSocketDevice::setDefaultImpl" cannot be defined in
          the current scope.

    KSocketDevice::setDefaultImpl(KSocketDeviceFactoryBase* factory)
    ^

cc-1553 CC: ERROR File = ksocketdevice.cpp, Line = 853
  The function "KNetwork::KSocketDevice::addNewImpl" cannot be defined in the
          current scope.

    void KSocketDevice::addNewImpl(KSocketDeviceFactoryBase* factory, int capabilities)
         ^

4 errors detected in the compilation of "ksocketdevice.cpp".

The following patch fixed it (again anonymous namespace problems):
--- kdecore/network/ksocketdevice.cpp.orig	2004-12-03 17:56:20.000000000 -0600
+++ kdecore/network/ksocketdevice.cpp	2004-12-04 01:37:18.000000000 -0600
@@ -771,91 +771,87 @@
   return new QSocketNotifier(m_sockfd, type);
 }
 
-namespace
+// simple class to avoid pointer stuff
+template<class T> class ptr
 {
-  // simple class to avoid pointer stuff
-  template<class T> class ptr
-  {
-    typedef T type;
-    type* obj;
-  public:
-    ptr() : obj(0)
-    { }
-
-    ptr(const ptr<T>& other) : obj(other.obj)
-    { }
-
-    ptr(type* _obj) : obj(_obj)
-    { }
-
-    ~ptr()
-    { }
-
-    ptr<T>& operator=(const ptr<T>& other)
-    { obj = other.obj; return *this; }
-
-    ptr<T>& operator=(T* _obj)
-    { obj = _obj; return  *this; }
-
-    type* operator->() const { return obj; }
-
-    operator T*() const { return obj; }
-
-    bool isNull() const
-    { return obj == 0; }
-  };
-
-  static KSocketDeviceFactoryBase* defaultImplFactory;
-  static QMutex defaultImplFactoryMutex;
-  typedef QMap<int, KSocketDeviceFactoryBase* > factoryMap;
-  static factoryMap factories;
+  typedef T type;
+  type* obj;
+public:
+  ptr() : obj(0)
+  { }
+
+  ptr(const ptr<T>& other) : obj(other.obj)
+  { }
+
+  ptr(type* _obj) : obj(_obj)
+  { }
+
+  ~ptr()
+  { }
+
+  ptr<T>& operator=(const ptr<T>& other)
+  { obj = other.obj; return *this; }
+
+  ptr<T>& operator=(T* _obj)
+  { obj = _obj; return  *this; }
+
+  type* operator->() const { return obj; }
+
+  operator T*() const { return obj; }
+
+  bool isNull() const
+  { return obj == 0; }
+};
+
+static KSocketDeviceFactoryBase* defaultImplFactory;
+static QMutex defaultImplFactoryMutex;
+typedef QMap<int, KSocketDeviceFactoryBase* > factoryMap;
+static factoryMap factories;
  
-  KSocketDevice* KSocketDevice::createDefault(KSocketBase* parent)
-  {
-    KSocketDevice* device = dynamic_cast<KSocketDevice*>(parent);
-    if (device != 0L)
-      return device;
-
-    KSocksSocketDevice::initSocks();
-
-    if (defaultImplFactory)
-      return defaultImplFactory->create(parent);
-
-    // the really default
-    return new KSocketDevice(parent);
-  }
-
-  KSocketDevice* KSocketDevice::createDefault(KSocketBase* parent, int capabilities)
-  {
-    KSocketDevice* device = dynamic_cast<KSocketDevice*>(parent);
-    if (device != 0L)
-      return device;
-
-    QMutexLocker locker(&defaultImplFactoryMutex);
-    factoryMap::ConstIterator it = factories.constBegin();
-    for ( ; it != factories.constEnd(); ++it)
-      if ((it.key() & capabilities) == capabilities)
-	// found a match
-	return it.data()->create(parent);
-
-    return 0L;			// no default
-  }
-
-  KSocketDeviceFactoryBase*
-  KSocketDevice::setDefaultImpl(KSocketDeviceFactoryBase* factory)
-  {
-    QMutexLocker locker(&defaultImplFactoryMutex);
-    KSocketDeviceFactoryBase* old = defaultImplFactory;
-    defaultImplFactory = factory;
-    return old;
-  }
-
-  void KSocketDevice::addNewImpl(KSocketDeviceFactoryBase* factory, int capabilities)
-  {
-    QMutexLocker locker(&defaultImplFactoryMutex);
-    if (factories.contains(capabilities))
-      delete factories[capabilities];
-    factories.insert(capabilities, factory);
-  }
+KSocketDevice* KSocketDevice::createDefault(KSocketBase* parent)
+{
+  KSocketDevice* device = dynamic_cast<KSocketDevice*>(parent);
+  if (device != 0L)
+    return device;
+
+  KSocksSocketDevice::initSocks();
 
+  if (defaultImplFactory)
+    return defaultImplFactory->create(parent);
+
+  // the really default
+  return new KSocketDevice(parent);
+}
+
+KSocketDevice* KSocketDevice::createDefault(KSocketBase* parent, int capabilities)
+{
+  KSocketDevice* device = dynamic_cast<KSocketDevice*>(parent);
+  if (device != 0L)
+    return device;
+
+  QMutexLocker locker(&defaultImplFactoryMutex);
+  factoryMap::ConstIterator it = factories.constBegin();
+  for ( ; it != factories.constEnd(); ++it)
+    if ((it.key() & capabilities) == capabilities)
+      // found a match
+      return it.data()->create(parent);
+
+  return 0L;			// no default
+}
+
+KSocketDeviceFactoryBase*
+KSocketDevice::setDefaultImpl(KSocketDeviceFactoryBase* factory)
+{
+  QMutexLocker locker(&defaultImplFactoryMutex);
+  KSocketDeviceFactoryBase* old = defaultImplFactory;
+  defaultImplFactory = factory;
+  return old;
+}
+
+void KSocketDevice::addNewImpl(KSocketDeviceFactoryBase* factory, int capabilities)
+{
+  QMutexLocker locker(&defaultImplFactoryMutex);
+  if (factories.contains(capabilities))
+    delete factories[capabilities];
+  factories.insert(capabilities, factory);
 }

-- 
albert chin (china@thewrittenword.com)
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic