v2.0.0
printf.h
Go to the documentation of this file.
1
2// \author (c) Marco Paland (info@paland.com)
3// 2014-2019, PALANDesign Hannover, Germany
4//
5// \license The MIT License (MIT)
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23// THE SOFTWARE.
24//
25// \brief Tiny printf, sprintf and snprintf implementation, optimized for speed on
26// embedded systems with a very limited resources.
27// Use this instead of bloated standard/newlib printf.
28// These routines are thread safe and reentrant.
29//
31
32#ifndef _PICO_PRINTF_H
33#define _PICO_PRINTF_H
34
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45#include "pico.h"
46#include <stdio.h>
47#include <stdarg.h>
48
49// PICO_CONFIG: PICO_PRINTF_ALWAYS_INCLUDED, Whether to always include printf code even if only called weakly (by panic), type=bool, default=1 in debug build 0 otherwise, group=pico_printf
50#ifndef PICO_PRINTF_ALWAYS_INCLUDED
51#ifndef NDEBUG
52#define PICO_PRINTF_ALWAYS_INCLUDED 1
53#else
54#define PICO_PRINTF_ALWAYS_INCLUDED 0
55#endif
56#endif
57
58#if LIB_PICO_PRINTF_PICO
59// weak raw printf may be a puts if printf has not been called,
60// so that we can support gc of printf when it isn't called
61//
62// it is called raw to distinguish it from the regular printf which
63// is in stdio.c and does mutex protection
64#if !PICO_PRINTF_ALWAYS_INCLUDED
65bool __printflike(1, 0) weak_raw_printf(const char *fmt, ...);
66bool weak_raw_vprintf(const char *fmt, va_list args);
67#else
68#define weak_raw_printf(...) ({printf(__VA_ARGS__); true;})
69#define weak_raw_vprintf(fmt,va) ({vprintf(fmt,va); true;})
70#endif
71
80int vfctprintf(void (*out)(char character, void *arg), void *arg, const char *format, va_list va);
81
82#else
83
84#define weak_raw_printf(...) ({printf(__VA_ARGS__); true;})
85#define weak_raw_vprintf(fmt,va) ({vprintf(fmt,va); true;})
86
87#endif
88
89#ifdef __cplusplus
90}
91#endif
92
93#endif // _PRINTF_H_
__printflike
int __printflike(1, 0) stdio_printf(const char *format
stdio_getchar Alias for printf that definitely does not go thru the implementation in the standard C ...
pico.h
stdio.h