[Interest] How prevent "Code will never be executed" when compiling "qDebug() << enumvar" ?
Edward Sutton
edward.sutton at subsite.com
Tue Dec 15 14:45:57 CET 2015
This hides the unreachable code warning from the compiler. Although almost as ugly as hiding it by wrapping inside "#ifdef QT_DEBUG”
QString enumValue;
QDebug(&enumValue) << this->d_ptr->trackerFileSend.state();
qDebug("%s", enumValue.toLatin1().data());
-Ed
On Dec 15, 2015, at 7:31 AM, Edward Sutton <edward.sutton at subsite.com<mailto:edward.sutton at subsite.com>> wrote:
On Dec 15, 2015, at 3:31 AM, Thiago Macieira <thiago.macieira at intel.com<mailto:thiago.macieira at intel.com>> wrote:
On Monday 14 December 2015 21:44:47 Edward Sutton wrote:
#ifdef QT_DEBUG // Fix iOS Clang warning "Code will never be executed"
qDebug() << "TapAndHoldGesture: " << tapAndHold->state();
#endif
>We have not seen this warning. What version of Xcode is this warning showing
up on?
Xcode 7.2.
In an attempt to reduce Xcode's nagging to accept it’s *many* recommended project settings, I have the following warning flags added to my qmake project. There are still another half-dozen recommended project settings that I have not figured out what the associated flags are.
The issue only shows up in release build. The following warnings are added to my qmake project for all builds.
# Silence warnings on OSX ( I do not get these on the OSX build VM? Same XCode 6.4? )
# qobject.h:108: warning: unknown warning group '-Winconsistent-missing-override', ignored [-Wunknown-pragmas]
QMAKE_CXXFLAGS_WARN_ON += -Wno-unknown-pragmas
Q_CLANG_WARN_BOOL_CONVERSION.name = CLANG_WARN_BOOL_CONVERSION
Q_CLANG_WARN_BOOL_CONVERSION.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_CLANG_WARN_BOOL_CONVERSION
Q_CLANG_WARN_CONSTANT_CONVERSION.name = CLANG_WARN_CONSTANT_CONVERSION
Q_CLANG_WARN_CONSTANT_CONVERSION.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_CLANG_WARN_CONSTANT_CONVERSION
Q_CLANG_WARN_EMPTY_BODY.name = CLANG_WARN_EMPTY_BODY
Q_CLANG_WARN_EMPTY_BODY.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_CLANG_WARN_EMPTY_BODY
Q_CLANG_WARN_ENUM_CONVERSION.name = CLANG_WARN_ENUM_CONVERSION
Q_CLANG_WARN_ENUM_CONVERSION.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_CLANG_WARN_ENUM_CONVERSION
Q_CLANG_WARN_INT_CONVERSION.name = CLANG_WARN_INT_CONVERSION
Q_CLANG_WARN_INT_CONVERSION.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_CLANG_WARN_INT_CONVERSION
Q_CLANG_WARN_UNREACHABLE_CODE.name = CLANG_WARN_UNREACHABLE_CODE
Q_CLANG_WARN_UNREACHABLE_CODE.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_CLANG_WARN_UNREACHABLE_CODE
Q_CLANG_WARN__DUPLICATE_METHOD_MATCH.name = CLANG_WARN__DUPLICATE_METHOD_MATCH
Q_CLANG_WARN__DUPLICATE_METHOD_MATCH.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_CLANG_WARN__DUPLICATE_METHOD_MATCH
Q_ENABLE_STRICT_OBJC_MSGSEND.name = ENABLE_STRICT_OBJC_MSGSEND
Q_ENABLE_STRICT_OBJC_MSGSEND.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_ENABLE_STRICT_OBJC_MSGSEND
Q_GCC_NO_COMMON_BLOCKS.name = GCC_NO_COMMON_BLOCKS
Q_GCC_NO_COMMON_BLOCKS.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_GCC_NO_COMMON_BLOCKS
Q_GCC_WARN_64_TO_32_BIT_CONVERSION.name = GCC_WARN_64_TO_32_BIT_CONVERSION
Q_GCC_WARN_64_TO_32_BIT_CONVERSION.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_GCC_WARN_64_TO_32_BIT_CONVERSION
Q_GCC_WARN_ABOUT_RETURN_TYPE.name = GCC_WARN_ABOUT_RETURN_TYPE
Q_GCC_WARN_ABOUT_RETURN_TYPE.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_GCC_WARN_ABOUT_RETURN_TYPE
Q_GCC_WARN_UNDECLARED_SELECTOR.name = GCC_WARN_UNDECLARED_SELECTOR
Q_GCC_WARN_UNDECLARED_SELECTOR.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_GCC_WARN_UNDECLARED_SELECTOR
Q_GCC_WARN_UNINITIALIZED_AUTOS.name = GCC_WARN_UNINITIALIZED_AUTOS
Q_GCC_WARN_UNINITIALIZED_AUTOS.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_GCC_WARN_UNINITIALIZED_AUTOS
Q_GCC_WARN_UNUSED_FUNCTION.name = GCC_WARN_UNUSED_FUNCTION
Q_GCC_WARN_UNUSED_FUNCTION.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_GCC_WARN_UNUSED_FUNCTION
Q_GCC_WARN_UNUSED_VARIABLE.name = GCC_WARN_UNUSED_VARIABLE
Q_GCC_WARN_UNUSED_VARIABLE.value = YES
QMAKE_MAC_XCODE_SETTINGS += Q_GCC_WARN_UNUSED_VARIABLE
Example:
Users/edward3/Documents/projects/build-tsr-iphoneos_clang_Qt_5_5_1_for_iOS_1-Release/obj/TSR.build/Release-iphoneos/TSR.build/Objects-normal/armv7/trackerconnection.o
/Users/edward3/Documents/projects/tsr-mobile-fileput/source/trackerconnection.cpp:219:18: error: code will never be executed [-Werror,-Wunreachable-code]
qDebug() << this->d_ptr->trackerFileSend.state();
^~
/Users/edward3/Documents/projects/tsr-mobile-fileput/source/trackerconnection.cpp:209:52: error: code will never be executed [-Werror,-Wunreachable-code]
qDebug() << "TrackerConnection::TrackerState:" << d_ptr->trackerState;
^~
2 errors generated.
-Ed
--
Thiago Macieira - thiago.macieira (AT) intel.com<http://intel.com/>
Software Architect - Intel Open Source Technology Center
_______________________________________________
Interest mailing list
Interest at qt-project.org<mailto:Interest at qt-project.org>
http://lists.qt-project.org/mailman/listinfo/interest
This email and any files transmitted with it from The Charles Machine Works, Inc. 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 the sender. Our company accepts no liability for the contents of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
_______________________________________________
Interest mailing list
Interest at qt-project.org<mailto:Interest at qt-project.org>
http://lists.qt-project.org/mailman/listinfo/interest
This email and any files transmitted with it from The Charles Machine Works, Inc. 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 the sender. Our company accepts no liability for the contents of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151215/94f291fe/attachment.html>
More information about the Interest
mailing list