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

List:       kde-core-devel
Subject:    Re: Pimpl copying
From:       Peter_Kümmel <syntheticpp () gmx ! net>
Date:       2006-07-15 6:31:24
Message-ID: 44B88BBC.1010207 () gmx ! net
[Download RAW message or body]

Brad Hards wrote:
> On Saturday 15 July 2006 00:42, Peter Kümmel wrote:
>> +#define KDE_PIMPL_BASE_MACRO(COPY_ACCESS,X) \
>> +COPY_ACCESS: \
>> +    X(const X##&); \
>> +    X##& operator=(const X##&); \
>> +private: \
>> +    class X##Private; \
>> +    X##Private * const d;
>> +
>> +#define KDE_PIMPL_ENABLE_COPY(X)  KDE_PIMPL_BASE_MACRO(public, X)
>> +#define KDE_PIMPL_DISABLE_COPY(X) KDE_PIMPL_BASE_MACRO(private,X)
>> +
>> +
>>  #endif /* _KDE_MACROS_H_ */
> Hmm, I'm having problems with this:
> 
> Building CXX object kdecore/CMakeFiles/kdecore.dir/ktempdir.o
> In file included from /home/bradh/coding/kdelibs/kdecore/ktempdir.cpp:50:
> /home/bradh/coding/kdelibs/kdecore/ktempdir.h:164:1: error: pasting "KTempDir" 
> and "&" does not give a valid preprocessing token
> /home/bradh/coding/kdelibs/kdecore/ktempdir.h:164:1: error: pasting "KTempDir" 
> and "&" does not give a valid preprocessing token
> /home/bradh/coding/kdelibs/kdecore/ktempdir.h:164:1: error: pasting "KTempDir" 
> and "&" does not give a valid preprocessing token
> 
> This is with
> gcc version 4.1.1 20060525 (Red Hat 4.1.1-1)
> 
> Brad

I've fixed this by changing KTempDir.h,
don't wanna touch kdemacros.h.cmake until the final solution.

Seems gcc does not like 'X##&', 'X &' should work.
Index: kdemacros.h.cmake
===================================================================
--- kdemacros.h.cmake   (revision 562532)
+++ kdemacros.h.cmake   (working copy)
@@ -413,8 +413,8 @@

 #define KDE_PIMPL_BASE_MACRO(COPY_ACCESS,X) \
 COPY_ACCESS: \
-    X(const X##&); \
-    X##& operator=(const X##&); \
+    X(const X &); \
+    X & operator=(const X &); \
 private: \
     class X##Private; \
     X##Private * const d;

Is this a gcc bug or is X##& an invalid preprocessor command?
[prev in list] [next in list] [prev in thread] [next in thread] 

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