Re: Using functions for MAX and MIN limitsthierusability.

From: George Greer (greerga@circlemud.org)
Date: 04/22/01


On Sat, 21 Apr 2001, Peter Ajamian wrote:

>Would it not be better if it were passed and returned a long, though so
>that it would be compatible with longs on 16 bit platforms?  Or maybe
>compilers would complain too much about the implicit conversion from long
>to something less than long on the return?

Perhaps you want:

`-Wconversion'
     Warn if a prototype causes a type conversion that is different
     from what would happen to the same argument in the absence of a
     prototype.  This includes conversions of fixed point to floating
     and vice versa, and conversions changing the width or signedness
     of a fixed point argument except when the same as the default
     promotion.

     Also, warn if a negative integer constant expression is implicitly
     converted to an unsigned type.  For example, warn about the
     assignment `x = -1' if `x' is unsigned.  But do not warn about
     explicit casts like `(unsigned) -1'.

You'll need to ignore a lot of system header stupidity though.

It's about time for me to wade through the GCC documentation again and find
every single nit-picky warning to feed the CircleMUD sources through.  I
did it around bpl13-ish era with a number of them.  -Wshadow is a
particularly evil one. :)

>Take that one step further and maybe even test for implementations that
>have a long long type (it won't be very long until all have long long
>types since C99 supports long long anyways).

If I use C99, I'm using types of the form 'int32', 'uint64', and the like,
not 'long long' and such. (Not the official names, just example.)

--
George Greer
greerga@circlemud.org

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST