forked from mpaland/printf
-
Notifications
You must be signed in to change notification settings - Fork 60
Closed
Description
When setting the option ALIAS_STANDARD_FUNCTION_NAMES to ON only the definitions inside printf.c will be affected. Inside printf.c https://github.com/eyalroz/printf/blob/develop/src/printf/printf.c#L54:
#if PRINTF_ALIAS_STANDARD_FUNCTION_NAMES
# define printf_ printf
# define sprintf_ sprintf
# define vsprintf_ vsprintf
# define snprintf_ snprintf
# define vsnprintf_ vsnprintf
# define vprintf_ vprintf
#endif
But in the printf.h there is no include "printf_config.h", thus the declarations will never be aliased.
It means that, if the option is set to ON and the library is compiled, installed and consumed:
#include "printf.h"
int main()
{
char c[64];
snprintf(c, sizeof(c), "%d %f", 5, 160.1);
return 0;
}
One gets compilation error:
main.cpp: In function ‘int main()’:
main.cpp:6:12: error: ‘snprintf’ was not declared in this scope
6 | snprintf(c, sizeof(c), "%d %f", 5, 160.1);
| ^~~~~~~~
Possible solutions:
- Install
printf_config.halong withprintf.hand put#include "printf.h"at the top ofprintf.h. - Generate
printf.hand rename the function names basing on theALIAS_STANDARD_FUNCTION_NAMESoption value. - Generate
printf.hby puttingPRINTF_ALIAS_STANDARD_FUNCTION_NAMESmacro dynamically at the top of theprintf.hfile during installation and usetarget_compile_definitions(printf PUBLIC PRINTF_ALIAS_STANDARD_FUNCTION_NAMES)for the build interface. - Other?
Metadata
Metadata
Assignees
Labels
No labels