Some Comments & Questions about ANSI C

Rex Jaeschke rex at aussie.UUCP
Tue Jun 13 11:01:12 AEST 1989


> 	errno.h	 - this will contain the #defines for error messages.
> 		   But will it contain the declaration "extern int errno" ?

Yes. This is the ONLY place errno should be declared. Not in math.h and 
not in stddef.h (where it lived until errno.h was created.)

> 	locale.h - This will contain "properties that depend on local
> 		   language, nationality, or culture".  Such as?

Prototypes for setlocale and localeconv functions, macro 
definitions for the LC_* family and the lconv structure template for 
all the currency info. This struct and the set of LC_* macros can be 
extended by the implementer.

> 	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).

typedefs: size_t, ptrdiff_t, wchar_t
macros: NULL, offsetof
That's all.

> 2. It seems to me that every time I want to #include <stdio.h>, I must
> also #include <stdarg.h> and <stddef.h> beforehand.

Each and every std header must be self-sufficient and MUST NOT 
#include any other std header. A common practice is/was to define 
va_end as ap = NULL. No can do 'cos NULL isn't defined in stdarg.h.

> 4. I'm still not entirely sure I understand "void *".  If I have a

A void pointer is assignment compatible with all "real" pointers and 
needs no explicit cast in assignment, passing arguments in, or getting 
values back from functions.

> 5. Does the standard say anything about where function definitions for
> fopen and opendir must go?  Also, is <dirent.h> mentioned in the
> standard, or is it up to the individual implementor to choose this?

fopen is stdio.h; opendir and direct.h non-std.

> 6. Finally, I see there's no strdup in ANSI C.  Sigh.  I guess it's

Correct.

Rex

----------------------------------------------------------------------------
Rex Jaeschke     | C Users Journal     |  Journal of C Language Translation
(703) 860-0091   | DEC PROFESSIONAL    |1810 Michael Faraday Drive, Suite 101
uunet!aussie!rex | Programmers Journal |     Reston, Virginia 22090, USA
----------------------------------------------------------------------------
Convener of the Numerical C Extensions Group (NCEG)
----------------------------------------------------------------------------



More information about the Comp.lang.c mailing list