[Development] Namespace macros for Qt Add-Ons

lars.knoll at nokia.com lars.knoll at nokia.com
Fri Dec 9 09:50:41 CET 2011


On 12/9/11 8:42 AM, "Haverinen Henry (Nokia-MP-Qt/Tampere)"
<henry.haverinen at nokia.com> wrote:

>Hi Lars,
>
>We've previously recommended that add-on modules should wrap their public
>interface in C++ namespaces like QtBluetooth, QtOrganizer, QtJsonDb and so
>on. 
>
>Should there be some guidance for the namespace macros? Especially the
>macros for using the namespace, which are used in application code. I
>assume they are introduced to prepare for the possibility of moving the
>module to Qt Essentials and removing the namespace.

Or if the namespace should change for some other reason and you want to
stay 100% source compatible.
>
>Now we have macros like:
>
>QTORGANIZER_USE_NAMESPACE
>QTBLUETOOTH_USE_NAMESPACE
>Q_USE_JSONDB_NAMESPACE
>
>So it's not consistent at the moment, which makes the macros
>non-guessable. What would be the right thing to do here?

I'm not a too big fan of these macros. The main question is whether they
are needed at all. 

It doesn't really save any effort in typing. 'using namespace
QtAddOn::JsonDb' is not really harder to type than the macro.

And if we change to a different namespace it's most likely for a reason,
and we would likely do some API changes in the process breaking SC. In
that case it might be just as ok if developers have to manually change the
using statement. At least everybody understands then that something has
changed.

Cheers,
Lars




More information about the Development mailing list