httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@algroup.co.uk>
Subject Re: [PATCH] Resolve BUILD warnings under ULTRIX/mips (take 3)
Date Sat, 11 Apr 1998 20:19:44 GMT
Dean Gaudet wrote:
> 
> And btw, as long as you're using templates, which are non-portable,

Phooey. ANSI C is non-portable. So what?

> I
> might as well give a C example that accomplishes exactly what you did:

Not exactly. It does rely on you getting the function right
(static_cast_unsigned), whereas static_cast<> in C++ is inherently safe.
Admittedly if you only have to write it once you are more likely to get
it right.

Also, you have to specify the source _and_ destination types with this
technique, which will, presumably, lead to a lot of functions in the
end...

> unsigned inline static_cast_unsigned(int x) { return (unsigned)x; }
> 
> unsigned foo(void)
> {
>     return static_cast_unsigned(foo);
> }

Hmmm ... so typing static_cast<> is "so much extra crap" in C++, but 10
times as much in C is acceptable. Talk about double standards!

> This works fine for generating errors on gcc.  And a #define version of
> static_cast_unsigned could be used everywhere else.

Errr? A #define version gets you back to where you were in the first
place. Or have I misunderstood?

> Thanks for the tip.

You're welcome.

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|  Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |
A.L. Digital Ltd,     |Apache-SSL author    http://www.apache-ssl.org/
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Mime
View raw message