Suggestions

Tony van der Hoff Postmaster at mk-net.demon.co.uk
Thu Apr 27 13:02:24 BST 2000


In message <200004262358.QAA01119 at purple.trimedia.sv.sc.philips.com>,
Jonathan Coxhead <jonathan at doves.demon.co.uk> writes
>
>   Now that's what I call a serious bug.
>
>   It's equally serious in all the cases where there's a |bool| 
>output parameter: e g, almost every service call, and common things 
>like
>
<snip>
>
>which, in C++, will be passed a byte pointer, and then write a word 
>to it. It doesn't get much worse than that, I'd say ...
>
Not much :-(

In the RISC OS environment, the 'bug' actually only exists under G++.
Neither C nor CFront define bool at all. How come G++ doesn't spot the
mis-use of the bool keyword in types.h?

This is a bit naughty:
 |   #ifdef __GNUG__
 |     #define bool dummy
 |     #include "types.h"
 |     #undef bool
 |   #endif


Coming back to my previous proposal:

1. In DefMod, ensure that .Bool translates to osbool

2. In types.h: 

typedef int osbool;

#if !defined( __GNUG__ ) && !defined( BOOL_DEFINED ) 
  typedef osbool bool;
#endif

This retains backward compatibility with everything compiled with C and
CFront.

G++ loses backward compatibility, but as it's a bug, it has to be fixed.
Any attempt at compilation using bool instead of osbool will throw an
error, so the user is aware of it. Obviously, old code using the
library, and compiled with G++ will need to be re-compiled, but I guess
there's not much we can do about that at this stage.

Any future limitation on the use of a 4-byte bool can be taken care of
by by the user defining BOOL_DEFINED, and using osbool.

Any objections so far? ;-)

Next, what to do with |TRUE| and |FALSE|? Apart from casting them to
|osbool| instead of |bool|, I'd be inclined to leave them alone; there
doesn't seem much point in changing them.

Next, should we change, as Jonathan suggested, |bits| and |byte| for
consistency? Again I'd be inclined to leave them alone; they are oslib-
specific anyway, and presently don't present a problem.
-- 
Postmaster, MK-Net        |  mailto:postmaster at mk-net.demon.co.uk
Buckinghamshire, England  |     
----------------------------------------------------------------



More information about the oslib-user mailing list