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

Peter Ross peter.ross at miscrit.be
Sat Aug 12 02:40:43 AEST 2000


On Sat, Aug 12, 2000 at 02:07:15AM +1000, Fergus Henderson wrote:
> 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;
> 	}

you forgot to add a variable declared with the hungarian notation.  :)

Pete

PS I removed the cast.
--------------------------------------------------------------------------
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