Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if __STDC_VERSION__ < 199901L
- #define STATIC_ALLOC(var, size) char *var = (char*)malloc(size);
- #define STATIC_FREE(var) free(var);
- int _expand_format_str(char *buffer, const char *format);
- #else
- #define STATIC_ALLOC(var, size) char var[size];
- #define STATIC_FREE(var)
- int _expand_format_str(char *restrict buffer, const char *restrict format);
- #endif
- /* ----------------------- Wrapping up standard io ----------------------- */
- #if __STDC_VERSION__ < 199901L
- int cprintf(const char *format, ...)
- #else
- int cprintf(const char *restrict format, ...)
- #endif
- {
- va_list args;
- int ret;
- STATIC_ALLOC(format_expanded, _expand_format_str(NULL, format));
- va_start(args, format);
- _expand_format_str(format_expanded, format);
- ret = vprintf(format_expanded, args);
- va_end(args);
- STATIC_FREE(format_expanded);
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement