On Tue, 16 May 2006, Martin Michlmayr wrote: > > #include <alsa/asoundlib.h> > > > > int main() > > { > > snd_pcm_hw_params_t *hwparams=NULL; > > assert(&hwparams); > > return 0; > > } > > > > $ gcc -Werror -Wall test.c -o test > > cc1: warnings being treated as errors > > test.c: In function 'main': > > test.c:6: warning: the address of 'hwparams', will always evaluate as 'true' > > > > Should I reassign this to gcc, or is it a bug in linphone (should I remove > > the -Werror)? > > GCC folks, can you comment?
Hmm. This is a complex one. The addresses of local variables are always non-NULL, as required by the C/C++ standards (and common sense). And its often the case explicitly testing this in code indicates a potential logic error, "assert (&hwparams)" instead of "assert (hwparams)" for example. However, in this particular case, because of the use of a macro, it does appear to be an annoying false negative. The work around is to use the GCC command-line option "-Wno-always-true" after "-Wall" on the command line, which will explicitly disable this warning. This provides slightly less error checking, but will allow the code to build silently. An alternate fix might be to recode the assert macro, into a function call which passes the Boolean expression as a parameter. This would hide the "if (<always_true>)" from the compiler. I hope this helps. Roger -- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]