On 05.03.2010, at 12:54, MacArthur, Ian (SELEX GALILEO, UK) wrote:
> I do find the braces cluttering the code.
> But, I like a "quiet" build, too.
Having quiets builds on all platforms is a great way of getting rid of those
little pesky typos and "light" bugs.
Brace make sens if expression look like typical typose
if (i=0) ... // did the programmer really want to assign a value to i?
For the & and | issue, I find it helpful because obviously, not everyone knows
by heart that & has precedence (I didn't...). Everything else is clutter.
>> Other warnings may be more useful, though:
>>
>> Fl_Preferences.cxx:684: warning: suggest explicit braces to avoid
>> ambiguous 'else'
>
> These we maybe should sort? Just in case...
Yes, absolutely. Especially since indenting could be different than actual
program flow.
>> Fl_Text_Buffer.cxx:1346: warning: array subscript has type 'char'
>
> Never really understood why this was "bad" - if the array is smaller
> than 127 elements, then a char is big enough?
Well, again, if for whatever reason someone feels like the index need more than
127 items, or someone assumes that char is unsigned, then this will lead to
errors.AFAIK, an 'int' is faster anyway bcause access is 32-bits no matter
what, and the char needs to be sign-expanded before it can be used as an index.
>> These were with gcc 4.x on Windows, but on Linux there are some more
>> like:
>>
>> Fl_File_Chooser2.cxx: In member function 'void
>> Fl_File_Chooser::fileNameCB()':
>> Fl_File_Chooser2.cxx:864: warning: format not a string literal and no
>> format arguments
>
> Yup - not even sure what that really means...
It means that for an expresion like printf("%d", x) , the compiler verifies
that x is actually an integer. However, if the string is not a literal, but a
variable, this test can not be done. These constructs are considered unsafe,
and so the newest gcc warn about it. This can of course be switched of, since
we use this as a feature in a library, not as an end product.
Bad:
int x = 0;
const char *p = "%s";
printf(p, x);
legal, but baad
- Matthias
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk