Boost logo

Boost-Commit :

From: dgregor_at_[hidden]
Date: 2008-01-14 12:01:26


Author: dgregor
Date: 2008-01-14 12:01:26 EST (Mon, 14 Jan 2008)
New Revision: 42767
URL: http://svn.boost.org/trac/boost/changeset/42767

Log:
Improved suggestion for dealing with Qt MOC, from Niels Dekker
Text files modified:
   trunk/libs/signals/doc/faq.xml | 30 +++++++++++++++++++++++-------
   1 files changed, 23 insertions(+), 7 deletions(-)

Modified: trunk/libs/signals/doc/faq.xml
==============================================================================
--- trunk/libs/signals/doc/faq.xml (original)
+++ trunk/libs/signals/doc/faq.xml 2008-01-14 12:01:26 EST (Mon, 14 Jan 2008)
@@ -86,23 +86,39 @@
   }
 </programlisting>
 
- <para>The second way, provided by Frank Hess, involves
+ <para>The second way, provided by Frank Hess and improved by
+ Niels Dekker, involves
         creating a header <code>signalslib.hpp</code> that contains
           the following code:</para>
 
- <programlisting>#ifdef signals
-#error "signalslib.hpp must be included before any qt header"
+ <programlisting>#ifndef SIGNALSLIB_HPP_INCLUDED
+#define SIGNALSLIB_HPP_INCLUDED
+
+#if defined(signals) && defined(QOBJECTDEFS_H) && \
+ !defined(QT_MOC_CPP)
+# undef signals
+# define signals signals
 #endif
 
 #include &lt;boost/signal.hpp&gt;
 namespace boost
 {
   namespace signalslib = signals;
-}</programlisting>
+}
+
+#if defined(signals) && defined(QOBJECTDEFS_H) && \
+ !defined(QT_MOC_CPP)
+# undef signals
+// Restore the macro definition of "signals", as it was
+// defined by Qt's &lt;qobjectdefs.h&gt;.
+# define signals protected
+#endif
+
+#endif</programlisting>
 
- <para>This header must be included before any Qt headers. Once
- it has been included, you can refer to the Signals library via
- the namespace <code>boost::signalslib</code>. This option is
+ <para>Use this header to include the Boost library, then refer
+ to it in the namespace <code>boost::signalslib</code>. This
+ option is often
         preferable to the first option because it can be used without
         recompiling the Signals library binary. </para>
       </answer>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk