Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cstdio name collision solution #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
extern "C" {
#endif


#if defined(PRINTF_FUNCTION_RENAME)
#define _PRINTF_GET_FNAME(base) PRINTF_FUNCTION_RENAME(base)
#else
#define _PRINTF_GET_FNAME(base) mp_##base
#endif
/**
* Output a character to a custom device like UART, used by the printf() function
* This function is declared here only. You have to write your custom implementation somewhere
Expand All @@ -57,7 +61,7 @@ void _putchar(char character);
* \param format A string that specifies the format of the output
* \return The number of characters that are written into the array, not counting the terminating null character
*/
#define printf printf_
#define printf_ _PRINTF_GET_FNAME(printf)
int printf_(const char* format, ...);


Expand All @@ -68,7 +72,7 @@ int printf_(const char* format, ...);
* \param format A string that specifies the format of the output
* \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character
*/
#define sprintf sprintf_
#define sprintf_ _PRINTF_GET_FNAME(sprintf)
int sprintf_(char* buffer, const char* format, ...);


Expand All @@ -82,8 +86,8 @@ int sprintf_(char* buffer, const char* format, ...);
* null character. A value equal or larger than count indicates truncation. Only when the returned value
* is non-negative and less than count, the string has been completely written.
*/
#define snprintf snprintf_
#define vsnprintf vsnprintf_
#define snprintf_ _PRINTF_GET_FNAME(snprintf)
#define vsnprintf_ _PRINTF_GET_FNAME(vsnprintf)
int snprintf_(char* buffer, size_t count, const char* format, ...);
int vsnprintf_(char* buffer, size_t count, const char* format, va_list va);

Expand All @@ -94,7 +98,7 @@ int vsnprintf_(char* buffer, size_t count, const char* format, va_list va);
* \param va A value identifying a variable arguments list
* \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character
*/
#define vprintf vprintf_
#define vprintf_ _PRINTF_GET_FNAME(vprintf)
int vprintf_(const char* format, va_list va);


Expand Down