Sunday 8 February 2009

Header Wrappers and "type qualifiers ignored on function return" warnings

"type qualifiers ignored on function return" warnings

I've been working with Polyworld which uses the Qt library.

Qt 4.3.1 was the first version of Qt that I worked with. It worked well except it produced the warning, "type qualifiers ignored on function return" when I compiled Polyworld. I wanted to compile Polyworld cleanly so I looked around for a way. I decided to try the next version.

Qt 4.3.2 is the first version with official Visual C++ support! This version, however, also produced the warning, "type qualifiers ignored on function return".

Qt 4.3.4 also produced the warning, "type qualifiers ignored on function return".

Qt 4.3.5 also produced the warning, "type qualifiers ignored on function return".

Qt 4.4.0 compiled cleanly! Originally, I though that Polyworld would not work with Qt 4.4.0 and onwards. This made me curious so I continued trying the later versions.

The later versions would not compile so I tried using "./configure -fast" to only compile the core parts.

Qt 4.4.1 would not compile. It produced the following messages:
In file included from ../../../include/QtCore/qlocale.h:1,
from ../../../include/QtGui/../../src/gui/widgets/qvalidator.h:50,
from ../../../include/QtGui/qvalidator.h:1,
from ../../../include/QtGui/../../src/gui/widgets/qabstractspinbox.h:48,
from ../../../include/QtGui/qabstractspinbox.h:1,
from ../../../include/QtGui/../../src/gui/styles/qstyleoption.h:48,
from ../../../include/QtGui/qstyleoption.h:1,
from ../../../include/QtGui/../../src/gui/itemviews/qabstractitemdelegate.h:48,
from ../../../include/QtGui/qabstractitemdelegate.h:1,
from ../../../include/QtGui/../../src/gui/itemviews/qabstractitemview.h:50,
from ../../../include/QtGui/qabstractitemview.h:1,
from ../../../include/QtGui/../../src/gui/itemviews/qtreeview.h:47,
from ../../../include/QtGui/qtreeview.h:1,
from ../../../include/QtGui/QTreeView:1,
from .uic/release-shared/ui_phrasebookbox.h:69,
from .moc/release-shared/../../phrasebookbox.h:47,
from .moc/release-shared/moc_phrasebookbox.cpp:10:
../../../include/QtCore/../../src/corelib/tools/qlocale.h:542: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See for instructions.
make[3]: *** [.obj/release-shared/moc_phrasebookbox.o] Error 1
make[3]: Leaving directory `/home/binh/Documents/qt-x11-opensource-src-4.4.1/tools/linguist/linguist'
make[2]: *** [sub-linguist-make_default-ordered] Error 2
make[2]: Leaving directory `/home/binh/Documents/qt-x11-opensource-src-4.4.1/tools/linguist'
make[1]: *** [sub-linguist-make_default-ordered] Error 2
make[1]: Leaving directory `/home/binh/Documents/qt-x11-opensource-src-4.4.1/tools'
make: *** [sub-tools-make_default-ordered] Error 2
Qt 4.4.2 would not compile.

Qt 4.4.3 would not compile. It produced the following messages:
../../sqlite/sqlite3.c: In function ‘unixRandomness’:
../../sqlite/sqlite3.c:18482: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result
collect2: ld returned 1 exit status
make[1]: *** [../../../../lib/libQtWebKit.so.4.4.3] Error 1
make: *** [sub-webkit-make_default-ordered] Error 2
I could go back and try to disable the parts related to sql and then try to compile but I am really annoyed by Qt. It is just a GUI layer making it a only a small part of my project but it is causing so many problems, from not compiling to only providing event driven input handling and not providing asynchronous input handling.

Header Wrappers

As I was searching around for ways to handle the warning, "type qualifiers ignored on function return", I stumbled upon the post, "How to lower warning level?" by Maciej Pilichowski which led me on to the idea about using a wrapper for files which you cannot modify but which produce warnings. This in turn led to the very cool site Artima Developer and an excerpt about from C++ Coding Standards" by Herb Sutter and Andrei Alexandrescu. The section, Compile cleanly at high warning levels from the excerpt detailed how to wrap header files. This is a must read book!

The "aha" example was the following:

#pragma warning(push) // disable for this header only
#pragma warning(disable:4512)
#pragma warning(disable:4180)
#include
#pragma warning(pop) // restore original warning level

Artima Developer is a cool site because it has frequent contributions from knowledgeable people such as Scott Meyers, author of such great books as "Effective C++".

No comments:

Post a Comment