Skip to content

Commit 94e0dfc

Browse files
author
Eyal Rozenberg
committed
Fixes #14: We now have a CMake build option, translated into a defined value, controlling whether or not to alias printf(), sprintf() etc.
1 parent 0cb6c66 commit 94e0dfc

File tree

3 files changed

+424
-405
lines changed

3 files changed

+424
-405
lines changed

CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ if (NOT SUPPORT_PTRDIFF_ARGUMENTS)
2929
add_definitions(-DPRINTF_DISABLE_SUPPORT_PTRDIFF_T)
3030
endif()
3131

32+
option(ALIAS_STANDARD_FUNCTION_NAMES "Alias the relevant standard library function (printf, sprintf etc.) to the library's implementations" ON)
33+
if (NOT ALIAS_STANDARD_FUNCTION_NAMES)
34+
add_definitions(-DALIAS_STANDARD_FUNCTION_NAMES)
35+
endif()
36+
37+
option(ALIAS_STANDARD_FUNCTION_NAMES "Alias the relevant standard library function (printf, sprintf etc.) to the library's implementations" ON)
38+
if (NOT ALIAS_STANDARD_FUNCTION_NAMES)
39+
add_definitions(-DALIAS_STANDARD_FUNCTION_NAMES)
40+
endif()
41+
3242
# numeric defines
3343

3444
set(INTEGER_TO_STRING_BUFFER_SIZE "32" CACHE STRING "Integer to string (ntoa) conversion buffer size")

printf.h

+9
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ __attribute__((format(__printf__, (one_based_format_index), (first_arg))))
4949
# define ATTR_VPRINTF(one_based_format_index)
5050
#endif
5151

52+
#ifdef ALIAS_STANDARD_FUNCTION_NAMES
53+
# define printf printf_
54+
# define sprintf sprintf_
55+
# define vsprintf vsprintf_
56+
# define snprintf snprintf_
57+
# define vsnprintf vsnprintf_
58+
# define vprintf vprintf_
59+
#endif
60+
5261

5362
/**
5463
* Output a character to a custom device like UART, used by the printf() function

0 commit comments

Comments
 (0)