C portability between non-UNIX o

rgh at inmet.UUCP rgh at inmet.UUCP
Sat Nov 10 16:51:53 AEST 1984


The ANSI C standards committee is addressing library standardization
as well as language issues.  To give you the flavor of what's being
discussed, here's the standard header files, and a few sample
declarations in each, from working drafts: 

<assert.h>
    #define assert(expression) ???
	/* complain if expression==0, unless the macro NDEBUG is defined */
<ctype.h>
    int isalpha(int);
    int tolower(int);
    /* etc. */
<math.h>
    double sin(double);
    /* acos,asin,fmod,log,sqrt,tanh,fabs,etc. */
    /* domain or range errors will post EDOM or ERANGE to errno */
    /* etc. */
<stdio.h>
    FILE * fopen(char *filename, char *mode);
    int sscanf(char *buffer, char *format, ...);
	/* format characters for printf/scanf/... are defined */
    /* defines an l-value errno, which is used for posting error codes */
    /* etc. */
<stdlib.h> -- general utility functions
    typedef ??? size_type;  /* int big enough to hold size of object*/
    void *calloc(unsigned int, size_type);
    void abort();
    int atoi(char *);
    void exit(int);
    /* etc. */
<setjmp.h>
    typedef ??? jmp_buf;  /* jmp_buf is an array */
    int setjmp(jmp_buf);
    void longjmp(jmp_buf,int);
<string.h>
    char *strcat(char *, char *);
    size_type strlen(char *);
    /* etc. */
<time.h>
    struct tm {
	int	tm_sec, tm_min  /* , etcetera */ ;
	int 	tm_isdst    	/* nonzero for daylight savings time */
	/* etc. */
    }
    typedef  /*some_int_type*/ time_t;
    char * asctime(struct tm *);
    struct tm *localtime(time_t *); /* convert to local time */
    double difftime(time_t, time_t); /* difference in seconds */
    /* etc. */
<vargs.h> -- to handle variable-length argument lists
    #define va_list ???
    #define va_start(ap, parmN, type)  ???
    #define va_arg(ap, type) ???
    #define va_end(ap)  ???

"Unless explicitly stated otherwise, any function or object declared
in a header may be redefined as a macro, within the header ... .
Unless explicitly stated otherwise, any macro ... will expand to
code that evaluates each of its arguments once ... ."

    Randy Hudson
    {ihnp4,harpo,ima}!inmet!rgh



More information about the Comp.lang.c mailing list