mpaland/printf

proposal: additional prefix to avoid name collision

diggit opened this issue · 3 comments

I propose to add prefix to all exposed functions using eg. macro. This is to avoid possible name collision with stdio and other libraries when used.

What do you think?

All exposed functions end with _, and there are defines which define the function name, e.g.

#define printf printf_
int printf_(const char* format, ...);

So IMHO there won't be a function name collision.

I noticed that it does an:
#undef printf

which results in a linker error when it tries to pull the global printf into the std namespace:
toolchain-xtensa32\xtensa-esp32-elf\include\c++\5.2.0\cstdio:127:11: error: '::printf' has not been declared

I don't understand why it can't find the original printf defined in stdio.h, but the is included by a 3rd party library.

On my fork, what I've done so far is make the aliasing of the standard-library function be disabled by default, with a CMake-controlled #define allowing it to happen if necessary.