RFC: Avoiding #warning (C/C++ preprocessor extension)

Nicolas Goutte nicolasg at snafu.de
Mon Oct 31 20:29:11 GMT 2005


On Monday 31 October 2005 16:11, Frans Englich wrote:
> On Sunday 30 October 2005 23:16, Olivier Goffart wrote:
> > Le Dimanche 30 Octobre 2005 21:25, Jarosław Staniek a écrit :
> > > Since KDE is becoming more portable, my proposal is to avoid using
> > > #warning C/C++ preprocessor's extension. Unlike #error, #warning is not
> > > a standard - several compilers in addition to gcc implement this. Msvc
> > > compiler does not.
> >
> > All of this is correct.
> > Anyway, #warning are just temporary code,  and they should be removed
> > before the release.
>
> Agreed. In my world, compiler warnings are indications to mistakes in code,
> and they should immediately be corrected. Thus, I understand using #warning
> for detecting when inclusions are wrong or similar, not communicating the
> roadmap of a project, which it in some cases are used like :}
>
> > A good code compiles without warnings at all.
>
> My view too, my current project compiles with:
>
> AM_CXXFLAGS = -pedantic -Wredundant-decls -Werror -Wunused-macros
> -Wfloat-equal
>
> I think it would be cool if for for example kdelibs, once the Qt port is
> over, that the compilation was made more strict, that the code gradually
> compiled with more warning flags. In cases where global enabled warnings
> can't be used, such as including C headers, compiling Bison parsers and
> similar, the warnings can be disabled locally with -W-no-*.
>
> GCC's warnings are for the most time valid and AFAICT everyone agrees that
> they shouldn't be there -- but no one cares enough for fixing it. Thus,
> adding "-Werror" and other options would raise the bar for what goes in and
> increase the general "tidyness". Just a thought.

No, please, no "-Werror" !!! GCC keeps modifying its warnings and therefore 
-Werror is unsuitable for portable code.

Linux has problems with each new GCC compiler version, because a few 
developers forces the use of -Werrror. We do not need to repeat the same 
error, especially that KDE is *not* supposed to compile with gcc only. (So 
what's good to add a gcc-isms to keep the compiler calm, just not to be able 
to compile the code anymore on non-gcc compiler.)

>

Have a nice day!

>
> Cheers,
>
> 		Frans





More information about the kde-core-devel mailing list