External definitions for important standard C functions
Expand the standard C library function prototypes in MetaC in https://github.com/metaborg/metac/tree/master/BaseC/external, such as strcpy, malloc, etc. Bonus points for a transformation on C files that tries to generate these external definitions.
Submitted by Gabriƫl Konat on 31 May 2013 at 12:01
Issue Log
I downloaded the glibc, but these header files are long and contain a lot of macros. For example the stdio.h is almost a 1000 lines.
Part of the file looks like.
__BEGIN_NAMESPACE_STD /* Write formatted output to STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int fprintf (FILE *__restrict __stream, const char *__restrict __format, ...); /* Write formatted output to stdout. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int printf (const char *__restrict __format, ...); /* Write formatted output to S. */ extern int sprintf (char *__restrict __s, const char *__restrict __format, ...) __THROWNL; /* Write formatted output to S from argument list ARG. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int vfprintf (FILE *__restrict __s, const char *__restrict __format, _G_va_list __arg); /* Write formatted output to stdout from argument list ARG. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int vprintf (const char *__restrict __format, _G_va_list __arg); /* Write formatted output to S from argument list ARG. */ extern int vsprintf (char *__restrict __s, const char *__restrict __format, _G_va_list __arg) __THROWNL; __END_NAMESPACE_STD
If we were to automatically transform this then we first need a Spoofax parsing of header files including macros. Then we can filter out all function prototypes.
Another way to do it is to write a fast simple script based on string manipulation. All strings in the standard namespace excluding all comments.
Standard C libraries can be included by external modules. These have to be declared manually.
Log in to post comments