diff options
Diffstat (limited to 'lib/stdio.h')
-rw-r--r-- | lib/stdio.h | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/stdio.h b/lib/stdio.h index f7c1846..9a0c41e 100644 --- a/lib/stdio.h +++ b/lib/stdio.h @@ -2,16 +2,20 @@ #include <stdarg.h> +#ifdef __cplusplus /** An object type used for streams */ -typedef struct kIoDevice { - int id; - /** Functions that prints a character to the stream */ - void (*putc)(const struct kIoDevice *, char); +struct kIoDevice { + /** Function that prints a character to the stream */ + virtual void putc(char) = 0; /** Function that prints a string to the stream */ - int (*puts)(const struct kIoDevice *, const char *, int); - /** Flush all buffers */ - void (*flush)(const struct kIoDevice *); -} FILE; + virtual int puts(const char *, int) = 0; + /** Flush write buffers */ + virtual void flush() = 0; +}; +typedef kIoDevice FILE; +#else +typedef void FILE; +#endif /** A FILE value corresponding to stdin, the keyboard buffer */ extern FILE *stdin; @@ -20,6 +24,9 @@ extern FILE *stdout; /** A FILE value corresponding to stderr, the uart */ extern FILE *stderr; +#ifdef __cplusplus +extern "C" { +#endif /** * Write the formatted string to stdout * @@ -36,3 +43,6 @@ int fprintf(FILE *restrict stream, const char *restrict format, ...); * Write the formatted string to stream; see printf */ int vfprintf(FILE *restrict stream, const char *restrict format, va_list ap); +#ifdef __cplusplus +} +#endif |