From 31673c0ac9b8164860833cbf416f17c233d90457 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 19 Nov 2022 15:53:58 +0100 Subject: [PATCH] Introduce format attribute --- kernel/src/arch/Serial.h | 3 ++- luna/Format.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/src/arch/Serial.h b/kernel/src/arch/Serial.h index 92a0725e..70553b25 100644 --- a/kernel/src/arch/Serial.h +++ b/kernel/src/arch/Serial.h @@ -1,4 +1,5 @@ #pragma once +#include #include namespace Serial @@ -7,5 +8,5 @@ namespace Serial void write(const char* str, usize size); void print(const char* str); void println(const char* str); - int printf(const char* str, ...); + int printf(const char* str, ...) _format(1, 2); } \ No newline at end of file diff --git a/luna/Format.h b/luna/Format.h index 71ad0659..e908f76c 100644 --- a/luna/Format.h +++ b/luna/Format.h @@ -3,6 +3,8 @@ #include #include +#define _format(n, m) __attribute__((format(printf, n, m))) + typedef int (*callback_t)(char, void*); isize cstyle_format(const char* format, callback_t callback, void* arg, va_list ap); \ No newline at end of file