typedefs, etc. - (nf)

ucbesvax.turner at ucbcad.UUCP ucbesvax.turner at ucbcad.UUCP
Sat Dec 31 01:33:32 AEST 1983


#R:cincy:-116500:ucbesvax:23100004:000:646
ucbesvax!turner    Dec 30 03:26:00 1983

Re: returning crafty boolean expressions

    typedef int BOOL;	/* ?! */

That's not what I do!  I have (in ~turner/include/macros.h):

    typedef enum { FALSE, TRUE } bool;

With this bool-type, the following causes a type-clash on return value warning:

    bool yes( )
    {
	    return getchar( ) == 'y';
    }

I would have to (and am willing to) say, instead:

    bool yes( )
    {
	    if (getchar( ) == 'y')
		return TRUE;
	    else
		return FALSE;
    }

If this grosses you out, you probably wouldn't want to look at any of the
rest of my code.  I like weak languages to be strongly typed.
---
Michael Turner (ucbvax!ucbesvax.turner)



More information about the Comp.unix mailing list