[m-dev.] for review: change MercuryFile structure

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Aug 12 02:07:15 AEST 2000


On 11-Aug-2000, Peter Ross <peter.ross at miscrit.be> wrote:
> On Fri, Aug 11, 2000 at 10:08:08PM +1000, Fergus Henderson wrote:
> > On 11-Aug-2000, Peter Ross <peter.ross at miscrit.be> wrote:
> > > +++ runtime/mercury_library_types.h	2000/08/11 11:02:23
> > ...
> > > +  #define MR_UNGETCH(mf, ch)	ungetc((int) (ch), MR_file(mf))
> > 
> > Why the cast to `(int)'?
>
> Because ungetc expects an int as its first argument.

So? 

If I should happen to accidentally pass a `char *' rather than a `char'
to MR_UNGETCH(), I would like to get at least a warning about it.  But
the cast here will most likely supress any such warning.

If, on the other hand, you leave the cast out, then if I pass a `char'
or an `int', everything will be fine, and if I pass a `char *', I'll
have considerably more chance of getting a compiler warning.

Would you have me cast the argument of every function call? ;-)

	int main() {
		printf((const char *) "hello world\n");
		return 0;
	}

-- 
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.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list