delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/14/13:56:51

From: Gautier DOT DeMontmollin AT maths DOT unine DOT ch
Newsgroups: comp.os.msdos.djgpp
Subject: Re: BOOL as char/int
Message-ID: <xs7LhvOXh0mB@nedcu4>
Date: 14 Apr 99 11:26:31 MET
References: <7ev4na$49a$1 AT lola DOT ctv DOT es>
Organization: University of Neuchatel, Switzerland
Lines: 32
NNTP-Posting-Host: nedcu4.unine.ch
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> Look at this:

> #include <stdio.h>
> 
> typedef char /*int*/ BOOL;
> #define TRUE 1
> #define FALSE 0
> 
> main() {
>    BOOL flag=(BOOL)isupper('E');
>    puts(flag?"*TRUE*":"*FALSE*");
>    return 0;
>    }
> 
> It fails with BOOL as char, but works as int
> Can someone explain this reasonably?
> It works well with Borland
> I have been using this typedef for years and it seems standard, robust,
> good, pretty, simple, near-machine, fast, compact...
> It seems gods of chaos are conquering the world of computing

Gods of old-fashioned programming, rather... People since 1970 have
found ways to have standard,...,compact typedefs you'll never
have to wonder whether it works or not...

flag: boolean:= isupper('E');
begin
  put(boolean'image(flag));

;-)
 
Gautier

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019