Skip to Content.
Sympa Menu

freetds - Re: [freetds] warnings, again

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Sebastien FLAESCH <sf AT 4js.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] warnings, again
  • Date: Tue, 18 Dec 2007 11:45:41 +0100

James,

I have probably underestimated the skills of FreeTDS developers and want
to apologies for this... and should not be that sarcastic...

Just wanted to share our experience in the C / C++ world...

We port our product on ~40 different platforms, including of course most
common OSes like Windows, Linux, AIX, HP/UX, Solaris, Mac OS/X, in both
32bits and 64bits architectures. If possible, we try to use the native C
compilers provided by the OS...

Porting on both UNIX and Windows platforms is an interesting challenge,
as you can imagine. Did you ever consider to compile the FreeTDS sources
on Windows with MSVC? I mean, we got other kind of warnings in our case.

For the story: We started to write in C++ (mainly for fashion reasons),
but as we faced too many port problems (g++ / native C++ compiler too
expensive), we re-wrote the whole project in C. This saved us a a lot of
money and time...

We realized that we don't need advanced OOP features, so C is just fine
for us...

Best regards,
Seb

James K. Lowden wrote:
Sebastien FLAESCH wrote:
You better fix (sooner or later) the problems, instead of hiding them by
turning off gcc warnings.

You knew I couldn't pass that up, didn't you? ;-)

I agree, as long as it's a question of "hiding" them. Where I think we
disagree is this: some warnings are dumb, and it's very easy to write
wrong, innocent-looking code that provokes no warnings.
What is your standard, btw? Are gcc's warnings better than others? Do
you try compiling your code on different compilers, architectures?
I don't doubt that code that provokes no warnings is generally better, and
some warnings -- as I've mentioned -- are helpful. But I'm disinclined to
grant gcc carte blanche over our coding standard. "Whatever gcc thinks is
good enough for me?" No. Especially when it makes C start to look like
Lisp.
I wish the folks at gcc hadn't added that bit of advice about && and ||,
and I especially wish they hadn't entangled it with other IMO useful
advice. Knowing that && comes before || is really basic C (no pun
intended)[1]. Is it really possible that someone who could actually *do*
anything with the FreeTDS code would be misled by (x && y || w && z)? What next, a warning about ?: being too confusing?
I fixed two bugs lately that our technicolor emergency broadcast warning
system didn't say boo about:

while ((bar = foo() != 2))

exits when foo() returns 17 but assigns 0 to bar

and
void foo(int a, unsigned int b) {
if ( a < b )
...
}

promotes 'a' to unsigned, meaning a >= b if a == -1.
You won't find a stronger advocate than me for writing pedantically
correct code. (Well, you might, but I'm more likeable, just ask him!) But a language with invisible sequence points that gladly dereferences
NULL pointers, doesn't track the size of allocated memory or the length of
strings, and insists that -1 > 0xFFFF sometimes, depending on how you
define each one, really has no business telling me to mind my parentheses.

Except for bitwise operators, of course.
--jkl

[1] I can't think of a single language where "and" doesn't come before
"or". I can think of one or two with *no* operator precedence except left
to right, but they ended up in La Brea. _______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds






Archive powered by MHonArc 2.6.24.

Top of Page