Xref: utzoo comp.lang.c:19295 comp.std.c:1274 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcvax!ukc!warwick!diamond!geoff From: geoff@cs.warwick.ac.uk (Geoff Rimmer) Newsgroups: comp.lang.c,comp.std.c Subject: Some Comments & Questions about ANSI C Message-ID: Date: 11 Jun 89 22:19:24 GMT Sender: news@warwick.ac.uk Followup-To: comp.lang.c Organization: Computer Science, Warwick University, UK Lines: 76 1. 15 standard include files are listed in K&R2. Only 12 are described in sufficient detail. The other three are errno.h - this will contain the #defines for error messages. But will it contain the declaration "extern int errno" ? locale.h - This will contain "properties that depend on local language, nationality, or culture". Such as? stddef.h - Definition of the type size_t (A7.4.8). But what else goes in here? ino_t and dev_t presumably stay in sys/types.h (8.6 p 181). 2. It seems to me that every time I want to #include , I must also #include and beforehand. This is to stop it barfing on the function declarations in like size_t fread( void *, size_t, size_t, FILE * ); /* size_t is defined in */ and int vprintf( const char *, va_list ); /* va_list is defined in */ I find this annoying sometimes, especially when working on a simple program that is only including to get _iobuf defined. Am I correct on this? 3. Am I missing something, or is "difftime" the most simple function around? It seems to me that it is essentially a subtract: double difftime( time_t t2, time_t t1) { return (double)t2 - t1; } In which case, why is it a function? I'd rather do a subtraction myself! 4. I'm still not entirely sure I understand "void *". If I have a function which takes as argument a void *, and I want to pass it the variable x (which could be of type char *, int *, or even float(*)(int,char*) ), do I have to CAST x to a (void *) when calling the function? Similarly, if the function then returned a void *, and I have a variable y of type int *, would I have to do y = (int *) function (......); ? 5. Does the standard say anything about where function definitions for fopen and opendir must go? Also, is mentioned in the standard, or is it up to the individual implementor to choose this? 6. Finally, I see there's no strdup in ANSI C. Sigh. I guess it's back to #define strdup(x) (strcpy(Malloc(strlen(x)+1),(x))) :-( Geoff One of these days, I'm going to write an ANSI C compiler. And whenever it encounters some code whose behavior is undefined (such as fflush(stdin);) it will draw a picture of Snow White (tm) on the screen, and then play Rule Brittania 3 times, before crashing with a segmentation fault, and leaving a while(1){fork();malloc(UINT_MAX);} running in the background. /---------------------------------------------------------------\ | GEOFF RIMMER | | email : geoff@uk.ac.warwick.cs | | address : Computer Science Dept, Warwick University, | | Coventry, England. | | PHONE : +44 203 692320 | | FAX : +44 865 726753 | \---------------------------------------------------------------/ "No representation without taxation!" - Rik Mayall, The New Statesman.