C++ namespace issues

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

C++ namespace issues

Marcel Wiesweg
Hi,

I found out that some DBus communication from ioslave to main app is a bit
broken (for db change notification). Debugging that, I have come to a point
where I want to persuade moc to put the Digikam namespace in front of signal
parameters. Easiest is to put it there in code as well, but does anyone know
if this is legal C++ (or if it will be rejected by strict compilers on other
platforms?):

namespace Digikam
{

class MyClass : public QObject
{
Q_OBJECT
signal:
        void mySignal(const Digikam::MyDigikamObject &);
        // I mean the extra "Digikam::" in the previous line
};

}

Thanks
Marcel
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

Re: C++ namespace issues

Gilles Caulier-4


2008/9/1 Marcel Wiesweg <[hidden email]>
Hi,

I found out that some DBus communication from ioslave to main app is a bit
broken (for db change notification). Debugging that, I have come to a point
where I want to persuade moc to put the Digikam namespace in front of signal
parameters. Easiest is to put it there in code as well, but does anyone know
if this is legal C++ (or if it will be rejected by strict compilers on other
platforms?):

namespace Digikam
{

class MyClass : public QObject
{
Q_OBJECT
signal:
       void mySignal(const Digikam::MyDigikamObject &);
       // I mean the extra "Digikam::" in the previous line
};

}

Thanks
Marcel

Marcel,

Using namespace X into a code wrapped with X namespace will generate an error if the right option from gcc is enable, else it will be fine. I don't know other compilers...

But in your case, this will not be a compiler problem, but a Qt moc pre-compiler issue. unforget than signal and slots are formated to standard C++ by moc before to be played by GCC. So, i think it will fine for us.

Best

Gilles

_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

Re: C++ namespace issues

Marcel Wiesweg

> Marcel,
>
> Using namespace X into a code wrapped with X namespace will generate an
> error if the right option from gcc is enable, else it will be fine. I don't
> know other compilers...
>
> But in your case, this will not be a compiler problem, but a Qt moc
> pre-compiler issue. unforget than signal and slots are formated to standard
> C++ by moc before to be played by GCC. So, i think it will fine for us.
>
> Best
>
> Gilles

I have tried to compile with -pedantic, and there is no warning reported from
gcc. Additionally, Qt docs for moc require that you fully qualify enums and
typedefs for your own class if you want to use them in slots:
class MyClass
{
Q_OBJECT
enum MyEnum {A,B,C};
signals:
        void mySignal(MyClass::MyEnum enum);
};
which I find pretty similar to the namespace issue.
I will go with this solution for now, we will see if this causes problems on
other platforms.

Marcel
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel