Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, June 2007
Qt 4.3.0: Visual Studio level 4 warnings


Message 1 in thread

I'm compiling with Visual Studio 2002, using Qt 4.3.0.

 

With level 4 warnings turned on (/W4) I get 'warning C4127: conditional
expression is constant'.

 

For example:

 

c:\Qt\4.3.0\src\corelib\tools\qvector.h(407)

   which is...

if (QTypeInfo<T>::isStatic) {

 

or

 

Qt\4.3.0\src\corelib\tools\qlist.h(331)

   which is...

else if (QTypeInfo<T>::isComplex)

 

Why are these conditional expressions seen as constant?

 

Sam Dutton
 





SAM DUTTON
SENIOR SITE DEVELOPER

200 GRAY'S INN ROAD
LONDON
WC1X 8XZ
UNITED KINGDOM
T +44 (0)20 7430 4496
F 
E SAM.DUTTON@xxxxxxxxx
WWW.ITN.CO.UK
Please Note:

 

Any views or opinions are solely those of the author and do not necessarily represent 
those of Independent Television News Limited unless specifically stated. 
This email and any files attached are confidential and intended solely for the use of the individual
or entity to which they are addressed. 
If you have received this email in error, please notify postmaster@xxxxxxxxx 

Please note that to ensure regulatory compliance and for the protection of our clients and business,
we may monitor and read messages sent to and from our systems.

Thank You.


Message 2 in thread

> With level 4 warnings turned on (/W4) I get 'warning C4127:
conditional
> expression is constant'.
> 
> c:\Qt\4.3.0\src\corelib\tools\qvector.h(407)
> 
>    which is...
> 
> if (QTypeInfo<T>::isStatic) {
> 
> Why are these conditional expressions seen as constant?

because they *are* (at runtime).

Basically it means the trolls made the mistake to check for traits (like
::isStatic) with an if() at runtime, instead of using overloading to
check for it at compile time.

recommended reading:
Effective C++ Third Edition 55 Specific Ways to Improve Your Programs
and Designs By Scott Meyers, Addison Wesley Professional ISBN:
0-321-33487-6 

The chapter "Item 47: Use traits classes for information about types"
handles exactly the problem.

Cheers,
Peter

--
 [ signature omitted ]