Introduce format attribute

This commit is contained in:
apio 2022-11-19 15:53:58 +01:00
parent 3cdf224b90
commit 31673c0ac9
2 changed files with 4 additions and 1 deletions

View File

@ -1,4 +1,5 @@
#pragma once #pragma once
#include <Format.h>
#include <Types.h> #include <Types.h>
namespace Serial namespace Serial
@ -7,5 +8,5 @@ namespace Serial
void write(const char* str, usize size); void write(const char* str, usize size);
void print(const char* str); void print(const char* str);
void println(const char* str); void println(const char* str);
int printf(const char* str, ...); int printf(const char* str, ...) _format(1, 2);
} }

View File

@ -3,6 +3,8 @@
#include <Types.h> #include <Types.h>
#include <stdarg.h> #include <stdarg.h>
#define _format(n, m) __attribute__((format(printf, n, m)))
typedef int (*callback_t)(char, void*); typedef int (*callback_t)(char, void*);
isize cstyle_format(const char* format, callback_t callback, void* arg, va_list ap); isize cstyle_format(const char* format, callback_t callback, void* arg, va_list ap);