jeff@isi-vaxa.ARPA (Jeffery A. Cavallaro) (08/30/85)
Well, for starters you should take a look at the specification for the portability definition file "stdtype.h" described in the PLUM HALL document "C PROGRAMMING STANDARDS AND GUIDELINES". The latest version I have is JAN-1982, edition 3. In this addition, stdtype is described in section 1.3. Every site should have a version for each particular machine type. In addition, I would suggest the following: #define FALSE 0 #define TRUE 1 #define EOL '\0' /* End-of-line */
peter@graffiti.UUCP (Peter da Silva) (08/31/85)
> #define FALSE 0 > #define TRUE 1 > #define EOL '\0' /* End-of-line */ #define EOL '\n' #define EOS '\0' ... unless, of course, you're on a really weird O/S.
pcf@drux3.UUCP (FryPC) (09/04/85)
> From: peter@graffiti.UUCP (Peter da Silva) > > #define FALSE 0 > > #define TRUE 1 > > #define EOL '\0' /* End-of-line */ > #define EOL '\n' > #define EOS '\0' > ... unless, of course, you're on a really weird O/S. Are you saying that defining EOL as '\0' is incorrect because it does not match exactly what your system does? Have you perhaps missed the point of this include file. Peter Fry drux3!pcf
lwall%sdcrdcf.uucp@BRL.ARPA (Larry Wall) (09/08/85)
Here's a chunk of code straight out of rn: /* some handy defs */ #define bool char #define TRUE (1) #define FALSE (0) #define Null(t) ((t)0) #define Nullch Null(char *) #define Nullfp Null(FILE *) #define Ctl(ch) (ch & 037) #define strNE(s1,s2) (strcmp(s1,s2)) #define strEQ(s1,s2) (!strcmp(s1,s2)) #define strnNE(s1,s2,l) (strncmp(s1,s2,l)) #define strnEQ(s1,s2,l) (!strncmp(s1,s2,l)) Larry Wall {allegra,burdvax,cbosgd,hplabs,ihnp4,sdcsvax}!sdcrdcf!lwall
rbp%investor.uucp@BRL.ARPA (Bob Peirce) (09/08/85)
> my personal favorite: > > #define EVER ;; > > then you can say: > > for(EVER) { > stuff; > } Why not just #define FOREVER for(;;) Then you can say FOREVER{ stuff; } I actually have that in my "local.h" file, yet I persist in using "for(;;)!
richw%ada-uts.uucp@BRL.ARPA (09/08/85)
>> I'm interested in coming up with an include file, say "handy.h", >> -- Rich Wagner > If people, when choosing names for functions, variables, files, etc, would > think at least briefly about what name would be the most meaningful to an > uninitiated reader, we readers would have a much easier time. I would > suggest you come up with names like types.h or ctlchars.h or whatever, > segregate them functionally and name them appropriately. > -- Bill Crews "segregate them functionally" -- I'm impressed :-) Now that you mention it, you've got a point. I originally didn't expect as many responses as I've gotten, so it will make sense to create several files (can you say ``modularity''?). Now, can we get back to the original question? Thanks to the replies I've gotten via e-mail -- a (personally edited; sorry) listing of ``good stuff'' will be posted soon... -- Rich
peter@graffiti.UUCP (Peter da Silva) (09/16/85)
> Are you saying that defining EOL as '\0' is incorrect because it does > not match exactly what your system does? No, just saying that as far as I know, no O/S uses '\0' for end-of-line. Also, every 'C' implementation that I have seen for systems that don't use '\n' for end-of-line has translated-mode I/O that maps \n into whatever line/record separators that are actually used. Including RSX (which doesn't have an end of line character: each line is a record containing the length, line #, and text). Basically, if you're going to give a sample handy.h file you might as well make it a common one. Finally, if '\0' was EOL, you still couldn't use it as such without redefining EOS (which is almost certainly going to be '\0' for any vaguely portable 'C').