[Development] Banning C++-style category logging from header files
Thiago Macieira
thiago.macieira at intel.com
Sun Aug 17 03:19:10 CEST 2014
The variadic macros we use in qCDebug, qCWarning, etc. (added in
b8a38a6737acd670d92197ca5b009590d9fd8a9c) use a GNU extension not supported in
ISO C++ and the C99 preprocessor: passing zero arguments to the ...
It appears that Clang, GCC, ICC and MSVC accept them unless we tell them to be
pedantic. So the use of the categorised logging is not broken and we can
continue to use it in Qt code. We just must ensure that in public headers, we
use only the printf-style form.
Or, better yet: DON'T use logging from public header. Move the logging to the
.cpp and avoid bloating the user's applications with the logging strings.
This was found when running headerscheck:
GCC:
error: ISO C99 requires rest arguments to be used
Clang:
error: must specify at least one argument for '...' parameter of variadic
macro [-Werror,-Wgnu-zero-variadic-macro-arguments]
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list