Home > Back-end >  JSON file containing all c standard library functions/prototypes?
JSON file containing all c standard library functions/prototypes?

Time:05-30

I am making my own programming language and need to call into the c standard library. I am wondering if anyone knows of any json files that contain all of the prototypes (ie function name and arguments in parser JSON, with argument type and function return type etc) for c standard library functions. For example, in my language, to print I call to the c printf. However, to do this, I parse it into a function definition in my language (it becomes @printf(string format, double x)). Thank you.

CodePudding user response:

"Annex B - Library summary" in the standard looks promising: http://port70.net/~nsz/c/c11/n1570.html#B

Not JSON though, you'll have to parse it.

CodePudding user response:

I wasn't able to find a parsed JSON file containing the prototypes, however, I was able to copy a column from the table on this website (I didn't know that I could copy only a single column using firefox). While this is not ideal, it is better than nothing. Here are the prototypes:

void abort(void);
int abs(int n);
double acos(double x);
char *asctime(const struct tm *time);
char *asctime_r (const struct tm *tm, char *buf);
double asin(double x);
void assert(int expression);
double atan(double x);
double atan2(double y, double x);
int atexit(void (*func)(void));
double atof(const char *string);
int atoi(const char *string);
long int atol(const char *string);
void *bsearch(const void *key, const void *base, size_t num, size_t size, int (*compare) (const void *element1, const void *element2));
wint_t btowc(int c);
void *calloc(size_t num, size_t size);
int catclose (nl_catd catd);
char *catgets(nl_catd catd, int set_id, int msg_id, const char *s);
nl_catd catopen (const char *name, int oflag);
double ceil(double x);
void clearerr(FILE *stream);
clock_t clock(void);
double cos(double x);
double cosh(double x);
char *ctime(const time_t *time);
char *ctime64(const time64_t *time);
char *ctime_r(const time_t *time, char *buf);
char *ctime64_r(const time64_t *time, char *buf);
double difftime(time_t time2, time_t time1);
double difftime64(time64_t time2, time64_t time1);
div_t div(int numerator, int denominator);
double erf(double x);
double erfc(double x);
void exit(int status);
double exp(double x);
double fabs(double x);
int fclose(FILE *stream);
FILE *fdopen(int handle, const char *type);
int feof(FILE *stream);
int ferror(FILE *stream);
int fflush(FILE *stream);
int fgetc(FILE *stream);
int fgetpos(FILE *stream, fpos_t *pos);
char *fgets(char *string, int n, FILE *stream);
wint_t fgetwc(FILE *stream);
wchar_t *fgetws(wchar_t *wcs, int n, FILE *stream);
int fileno(FILE *stream);
double floor(double x);
double fmod(double x, double y);
FILE *fopen(const char *filename, const char *mode);
int fprintf(FILE *stream, const char *format-string, arg-list);
int fputc(int c, FILE *stream);
int fputs(const char *string, FILE *stream);
wint_t fputwc(wchar_t wc, FILE *stream);
int fputws(const wchar_t *wcs, FILE *stream);
size_t fread(void *buffer, size_t size, size_t count, FILE *stream);
void free(void *ptr);
FILE *freopen(const char *filename, const char *mode, FILE *stream);
double frexp(double x, int *expptr);
int fscanf(FILE *stream, const char *format-string, arg-list);
int fseek(FILE *stream, long int offset, int origin);
int fsetpos(FILE *stream, const fpos_t *pos);
long int ftell(FILE *stream);
int fwide(FILE *stream, int mode);
int fwprintf(FILE *stream, const wchar_t *format, arg-list);
size_t fwrite(const void *buffer, size_t size,size_t count, FILE *stream);
int fwscanf(FILE *stream, const wchar_t *format, arg-list)
double gamma(double x);
int getc(FILE *stream);
int getchar(void);
char *getenv(const char *varname);
char *gets(char *buffer);
wint_t getwc(FILE *stream);
wint_t getwchar(void);
struct tm *gmtime(const time_t *time);
struct tm *gmtime64(const time64_t *time);
struct tm *gmtime_r (const time_t *time, struct tm *result);
struct tm *gmtime64_r (const time64_t *time, struct tm *result);
double hypot(double side1, double side2);
int isalnum(int c);
int isalpha(int c);
int isascii(int c);
int isblank(int c);
int iscntrl(int c);
int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
int ispunct(int c);
int isspace(int c);
int isupper(int c);
int iswalnum (wint_t wc);
int iswalpha (wint_t wc);
int iswblank (wint_t wc);
int iswcntrl (wint_t wc);
int iswctype(wint_t wc, wctype_t wc_prop);
int iswdigit (wint_t wc);
int iswgraph (wint_t wc);
int iswlower (wint_t wc);
int iswprint (wint_t wc);
int iswpunct (wint_t wc);
int iswspace (wint_t wc);
int iswupper (wint_t wc);
int iswxdigit (wint_t wc);
int isxdigit(int c);
double j0(double x);
double j1(double x);
double jn(int n, double x);
long int labs(long int n);
double ldexp(double x, int exp);
ldiv_t ldiv(long int numerator, long int denominator);
struct lconv *localeconv(void);
struct tm *localtime(const time_t *timeval);
struct tm *localtime64(const time64_t *timeval);
struct tm *localtime_r (const time_t *timeval, struct tm *result);
struct tm *localtime64_r (const time64_t *timeval, struct tm *result);
double log(double x);
double log10(double x);
void longjmp(jmp_buf env, int value);
void *malloc(size_t size);
int mblen(const char *string, size_t n);
int mbrlen (const char *s, size_t n, mbstate_t *ps);
int mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
int mbsinit (const mbstate_t *ps);
size_t mbsrtowc (wchar_t *dst, const char **src, size_t len, mbstate_t *ps);
size_t mbstowcs(wchar_t *pwc, const char *string, size_t n);
int mbtowc(wchar_t *pwc, const char *string, size_t n);
void *memchr(const void *buf, int c, size_t count);
int memcmp(const void *buf1, const void *buf2, size_t count);
void *memcpy(void *dest, const void *src, size_t count);
void *memmove(void *dest, const void *src, size_t count);
void *memset(void *dest, int c, size_t count);
time_t mktime(struct tm *time);
time64_t mktime64(struct tm *time);
double modf(double x, double *intptr);
double nextafter(double x, double y);
long double nextafterl(long double x, long double y);
double nexttoward(double x, long double y);
long double nexttowardl(long double x, long double y);
char *nl_langinfo(nl_item item);
void perror(const char *string);
double pow(double x, double y);
int printf(const char *format-string, arg-list);
int putc(int c, FILE *stream);
int putchar(int c);
int *putenv(const char *varname);
int puts(const char *string);
wint_t putwchar(wchar_t wc, FILE *stream);
wint_t putwchar(wchar_t wc);
void qsort(void *base, size_t num, size_t width, int(*compare)(const void *element1, const void *element2));
_Decimal32 quantized32(_Decimal32 x, _Decimal32 y);
_Decimal64 quantized64(_Decimal64 x, _Decimal64 y);
_Decimal128 quantized128(_Decimal128 x, _Decimal128 y);
int quantexpd32(_Decimal32 x);
int quantexpd64(_Decimal64 x);
int quantexpd128(_Decimal128 x);
__bool__ samequantumd32(_Decimal32 x, _Decimal32 y);
__bool__ samequantumd64(_Decimal64 x, _Decimal64 y);
__bool__ samequantumd128(_Decimal128 x, _Decimal128 y);
int raise(int sig);
int rand(void);
int rand_r(void);
void *realloc(void *ptr, size_t size);
int regcomp(regex_t *preg, const char *pattern, int cflags);
size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size);
int regexec(const regex_t *preg, const char *string, size_t nmatch, regmatch_t *pmatch, int eflags);
void regfree(regex_t *preg);
int remove(const char *filename);
int rename(const char *oldname, const char *newname);
void rewind(FILE *stream);
int scanf(const char *format-string, arg-list);
void setbuf(FILE *stream, char *buffer);
int setjmp(jmp_buf env);
char *setlocale(int category, const char *locale);
int setvbuf(FILE *stream, char *buf, int type, size_t size);
void(*signal (int sig, void(*func)(int))) (int);
double sin(double x);
double sinh(double x);
int snprintf(char *outbuf, size_t n, const char*, ...)
int sprintf(char *buffer, const char *format-string, arg-list);
double sqrt(double x);
void srand(unsigned int seed);
int sscanf(const char *buffer, const char *format, arg-list);
int srtcasecmp(const char *string1, const char *string2);
char *strcat(char *string1, const char *string2);
char *strchr(const char *string, int c);
int strcmp(const char *string1, const char *string2);
int strcoll(const char *string1, const char *string2);
char *strcpy(char *string1, const char *string2);
size_t strcspn(const char *string1, const char *string2);
char *strerror(int errnum);
int strfmon (char *s, size_t maxsize, const char *format, ...);
size_t strftime (char *dest, size_t maxsize, const char *format, const struct tm *timeptr);
size_t strlen(const char *string);
int strncasecmp(const char *string1, const char *string2, size_t count);
char *strncat(char *string1, const char *string2, size_t count);
int strncmp(const char *string1, const char *string2, size_t count);
char *strncpy(char *string1, const char *string2, size_t count);
char *strpbrk(const char *string1, const char *string2);
char *strptime (const char *buf, const char *format, struct tm *tm);
char *strrchr(const char *string, int c);
size_t strspn(const char *string1, const char *string2);
char *strstr(const char *string1, const char *string2);
double strtod(const char *nptr, char **endptr);
_Decimal32 strtod32(const char *nptr, char **endptr);
_Decimal64 strtod64(const char *nptr, char **endptr);
_Decimal128 strtod128(const char *nptr, char **endptr);
float strtof(const char *nptr, char **endptr);
char *strtok(char *string1, const char *string2);
char *strtok_r(char *string, const char *seps, char **lasts);
long int strtol(const char *nptr, char **endptr, int base);
long double strtold(const char *nptr, char **endptr);
unsigned long int strtoul(const char *string1, char **string2, int base);
size_t strxfrm(char *string1, const char *string2, size_t count);
int swprintf(wchar_t *wcsbuffer, size_t n, const wchar_t *format, arg-list);
int swscanf (const wchar_t *buffer, const wchar_t *format, arg-list)
int system(const char *string);
double tan(double x);
double tanh(double x);
time_t time(time_t *timeptr);
time64_t time64(time64_t *timeptr);
FILE *tmpfile(void);
char *tmpnam(char *string);
int toascii(int c);
int tolower(int c);
int toupper(int c);
wint_t towctrans(wint_t wc, wctrans_t desc);
wint_t towlower (wint_t wc);
wint_t towupper (wint_t wc);
int ungetc(int c, FILE *stream);
wint_t ungetwc(wint_t wc, FILE *stream);
var_type va_arg(va_list arg_ptr, var_type);
void va_copy(va_list dest, va_list src);
void va_end(va_list arg_ptr);
void va_start(va_list arg_ptr, variable_name);
int vfprintf(FILE *stream, const char *format, va_list arg_ptr);
int vfscanf(FILE *stream, const char *format, va_list arg_ptr);
int vfwprintf(FILE *stream, const wchar_t *format, va_list arg);
int vfwscanf(FILE *stream, const wchar_t *format, va_list arg_ptr);
int vprintf(const char *format, va_list arg_ptr);
int vscanf(const char *format, va_list arg_ptr);
int vsprintf(char *target-string, const char *format, va_list arg_ptr);
int vsnprintf(char *outbuf, size_t n, const char*, va_list);
int vsscanf(const char*buffer, const char *format, va_list arg_ptr);
int vswprintf(wchar_t *wcsbuffer, size_t n, const wchar_t *format, va_list arg);
int vswscanf(const wchar_t *buffer, const wchar_t *format, va_list arg_ptr);
int vwprintf(const wchar_t *format, va_list arg);
int vwscanf(const wchar_t *format, va_list arg_ptr);
int wcrtomb (char *s, wchar_t wchar, mbstate_t *pss);
wchar_t *wcscat(wchar_t *string1, const wchar_t *string2);
wchar_t *wcschr(const wchar_t *string, wchar_t character);
int wcscmp(const wchar_t *string1, const wchar_t *string2);
int wcscoll (const wchar_t *wcs1, const wchar_t *wcs2);
wchar_t *wcscpy(wchar_t *string1, const wchar_t *string2);
size_t wcscspn(const wchar_t *string1, const wchar_t *string2);
size_t wcsftime(wchar_t *wdest, size_t maxsize, const wchar_t *format, const struct tm *timeptr);
size_t wcslen(const wchar_t *string);
struct wcslconv *wcslocaleconv(void);
wchar_t *wcsncat(wchar_t *string1, const wchar_t *string2, size_t count);
int wcsncmp(const wchar_t *string1, const wchar_t *string2, size_t count);
wchar_t *wcsncpy(wchar_t *string1, const wchar_t *string2, size_t count);
wchar_t *wcspbrk(const wchar_t *string1, const wchar_t *string2);
wchar_t *wcsptime ( const wchar_t *buf, const wchar_t *format, struct tm *tm );
wchar_t *wcsrchr(const wchar_t *string, wchar_t character);
size_t wcsrtombs (char *dst, const wchar_t **src, size_t len, mbstate_t *ps);
size_t wcsspn(const wchar_t *string1, const wchar_t *string2);
wchar_t *wcsstr(const wchar_t *wcs1, const wchar_t *wcs2);
double wcstod(const wchar_t *nptr, wchar_t **endptr);
_Decimal32 wcstod32(const wchar_t *nptr, wchar_t **endptr);
_Decimal64 wcstod64(const wchar_t *nptr, wchar_t **endptr);
_Decimal128 wcstod128(const wchar_t *nptr, wchar_t **endptr);
float wcstof(const wchar_t *nptr, wchar_t **endptr);
wchar_t *wcstok(wchar_t *wcs1, const wchar_t *wcs2, wchar_t **ptr)
long int wcstol(const wchar_t *nptr, wchar_t **endptr, int base);
long double wcstold(const wchar_t *nptr, wchar_t **endptr);
size_t wcstombs(char *dest, const wchar_t *string, size_t count);
unsigned long int wcstoul(const wchar_t *nptr, wchar_t **endptr, int base);
size_t wcsxfrm (wchar_t *wcs1, const wchar_t *wcs2, size_t n);
int wctob(wint_t wc);
int wctomb(char *string, wchar_t character);
wctrans_t wctrans(const char *property);
wctype_t wctype (const char *property);
int wcswidth(const wchar_t *pwcs, size_t n);
wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n);
int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n);
wchar_t *wmemcpy(wchar_t *s1, const wchar_t *s2, size_t n);
wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2, size_t n);
wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n);
int wprintf(const wchar_t *format, arg-list);
int wscanf(const wchar_t *format, arg-list);
double y0(double x);
double y1(double x);
double yn(int n, double x);

  •  Tags:  
  • c
  • Related