[bt-devel] Problems with GCC 4.3.2 on Kubuntu 8.10
Eeli Kaikkonen
eekaikko at mail.student.oulu.fi
Tue Nov 4 15:11:56 MST 2008
Martin Gruner wrote:
> Hi all,
>
> I'm getting tons of compiler warnings on BT and Sword.
>
> "warning: type qualifiers ignored on function return type"
>
> In all kinds of places. I haven't yet found out what exactly causes these
> warnings. I seem to be unable to turn them off with "-Wno-return-type". It
> seems that in C, functions cannot return const values, I am not sure about
> C++. Is this behaviour correct? Do we need to change our codebase and remove
> all const qualifiers on function return types?
>
> Can somebody please enlight me? ;)
>
Isn't this the same problem somebody found before and I fixed in some
places? There are quite many "const QString get()" style functions but
they don't make any sense because the returned QString is a copy, not
original, and calling it const is meaningless. "QString get() const" is
very meaningful, it tells that the method doesn't change member data.
So, all "const xxx xxx();" functions should probably be changed to "xxx
xxx() const;". It may trigger some other compilation problems if the
function changes some member data. If it happens it's easier to remove
the const but then we loose compile time safety checks and possibly
there is some logic but in the code because getter method shouldn't
usually change anything. If necessary a const data may be cast to
non-const with const_cast<>() or something like that (IIRC).
Are you enlightened? :)
--Eeli Kaikkonen
More information about the bt-devel
mailing list