On Thu, 20 Sep 2001 21:03:20 +0200, eric pouech eric.pouech@wanadoo.fr wrote:
(resent because of mail issues)
still thinking about it, there is however some points I don't like (and especially for keeping it permanent) errors we want to catch are mainly related to sign mismatch (like min(char, unsigned short)...)
however, comparaisons like min(short, int) or min(size_t, DWORD) don't provide lots of errors. integral promotions are straightforward, and behave as expected by any programmer. so it would be rather ugly IMO to write something like min((int)s, i) (s being short and i int)
on the other hand, in the case of min(char, unsigned short), only experienced programmers are able to tell the order of integral promotions involved here, and we really do need some guidance here. unfortunately, I don't see any ways not to let the min/max macro only spit errors on integral type of same sign-ness
Another argument in the L-K debate was that precisely the same problem exists when comparing variables... and comparisons are much more common then min/max. One person suggested a LE/GT/etc set of #defines to capture those errors. Not an easy job.
john