我正在使用 gcc-arm-none-eabi 工具链(当前为 7.2.1)设置和环境。这适用于 ARM cortex M4 嵌入式设备。
我想为整个项目重新定义 printf,但我遇到了麻烦。我想使用这个实现。我已经将它安装到项目中,我可以通过调用来使用它,例如:printf_("Test: %i",5);
并且一切都按预期工作。
现在我想将它设置为默认的 printf 函数。如果我取消注释: #define printf printf_
,我会收到以下错误:
/home/timv/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/arm-none-eabi/include/c++/7.2.1/cstdio:127:11: error: '::printf' has not been declared
using ::printf;
稍后的:
src/LoggerTask.cpp:62:5: error: 'printf' was not declared in this scope
在那个文件中,我找到了这一行:
#undef printf
当我注释掉该行时,项目构建,并且 printf 工作。这很好,但我想在不修补工具链的情况下拥有我的项目功能。
我该怎么做呢?还有哪些信息会有所帮助?