[m-dev.] std.h

Fergus Henderson fjh at cs.mu.oz.au
Tue Feb 11 18:27:08 AEDT 1997


Tyson Richard DOWD, you wrote:
> 
> In runtime/std.h, we have the following code:
> 
> #ifndef bool
> #define bool            char
> #endif
> 
> Is there any particular reason why this isn't a typedef?

Tom is right about the historical reasons.  But one reason that I left
it unchanged is that `bool' is a rather commonly used name -- for
example, it defined by <curses.h>.  I figured that a conditional
#define is a little less likely to conflict with other uses of `bool'.

> (I'm asking because it has this horrible tendency to rename
> 'bool' to 'char' which makes it difficult to initialise the
> base_type_info for bool without it trying to initialise the
> base_type_info for char... which of course is just not defined
> in bool.c).

I don't quite understand here.  The automatically-generated
C code for bool.m should not use any unqualified names such as `bool',
instead it should use names that include `mercury' somewhere in them.

If `bool.m' breaks because "std.h" is #included, then user's Mercury
programs might also break if they have pragma c_header_code("#include
<blah.h>") where <blah.h> defines a name that is the same as a type
name defined in the Mercury program.  So I think the correct fix does
not involve changing "std.h".

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list