[cfe-dev] Clang: QT header compilation error

Stephen Kelly steveire at gmail.com
Mon Nov 19 11:05:11 PST 2012


Matthieu Monrocq wrote:

> On Mon, Nov 19, 2012 at 2:08 PM, Dmitri Gribenko
> <gribozavr at gmail.com>wrote:
> 
>> On Mon, Nov 19, 2012 at 3:02 PM, Sujit Kamthe
>> <Sujit.Kamthe at kpitcummins.com> wrote:
>> >
>> > Hi,
>> >
>> > While I was running clang on a QT code, It flagged a compilation error
>> > in a standard QT header file.
>> >
>> > include\QtCore/qvector.h:565:12: error: missing 'typename'
>> >
>> >       prior to dependent type name 'QVector<T>::iterator'
>> >
>> > Q_TYPENAME QVector<T>::iterator QVector<T>::insert(iterator before,...
>> >
>> >            ^~~~~~~~~~~~~~~~~~~~
>> >
>> > include\QtCore/qvector.h:599:12: error: missing 'typename'
>> >
>> >       prior to dependent type name 'QVector<T>::iterator'
>> >
>> > Q_TYPENAME QVector<T>::iterator QVector<T>::erase(iterator abegin,...
>> >
>> >            ^~~~~~~~~~~~~~~~~~~~
>> >
>> >
>> >
>> > Attaching the header file along.
>>
>> Hi Sujit,
>>
>> Unfortunately, the header file alone is not helpful.  It is not
>> obvious what Q_TYPENAME expands to.  Could you please provide a
>> preprocessed file?  (Just replace -c with -E on the compilation
>> command line that is failing.)
>>
>> Dmitri
>>
>> --
>> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
>> (j){printf("%d\n",i);}}} /*Dmitri Gribenko
>> <gribozavr at gmail.com>*/
>> _______________________________________________ cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
> 
> At a glance (given the diagnostic and the macro) I suppose that Q_TYPENAME
> should have expanded into typename (which would have made the code
> correct) and did not.
> 
> As such, the preprocessed source will only be of moderate usefulness
> (confirming the diagnosis) and we will also need the definition of this
> Q_TYPENAME macro. It's probably defined differently depending on the
> platform and mistake clang for a non-compliant compiler.
> 
> -- Matthieu

I tried to reproduce this in my Qt 4 build, but I could not reproduce it:

stephen at hal:~/dev/prefix/qt48/include$ clang++ -I. -E QtCore/qvector.h  > 
out
clang-3: warning: treating 'c-header' input as 'c++-header' when in C++ 
mode, this behavior is deprecated
stephen at hal:~/dev/prefix/qt48/include$ l
out  Qt3Support/  QtDBus/         QtDesigner/  QtHelp/        QtNetwork/  
QtScript/       QtSql/  QtTest/     QtWebKit/  QtXmlPatterns/
Qt/  QtCore/      QtDeclarative/  QtGui/       QtMultimedia/  QtOpenGL/   
QtScriptTools/  QtSvg/  QtUiTools/  QtXml/


>From my reading qglobal.h, Q_TYPENAME should be 'typename' everywhere except 
some ancient DEC C++ and ancient xlC compilers.

Thanks,

Steve.





More information about the cfe-dev mailing list