provide a weak print char impl #674

Merged
mohr merged 2 commits from mueller/provide-weak-print-char into development 2022-09-12 14:10:32 +02:00
2 changed files with 12 additions and 0 deletions

View File

@ -1 +1,3 @@
add_subdirectory(gpio)
target_sources(${LIB_FSFW_NAME} PRIVATE printChar.c)

View File

@ -0,0 +1,10 @@
#include <stdio.h>
#include <stdbool.h>
void __attribute__((weak)) printChar(const char* character, bool errStream) {
Review
Does not build with MSVC https://godbolt.org/z/s8hav4sdn There seems to be solution for MSVC https://stackoverflow.com/questions/2290587/gcc-style-weak-linking-in-visual-studio
Review

Wow, this looks.. interesting. Yet another MS specific solution

Wow, this looks.. interesting. Yet another MS specific solution
Review

The solution above is for an extern const char*.
Actually, https://docs.microsoft.com/en-us/cpp/cpp/selectany?view=msvc-170 might work as well. I can't really test this as MSVC does not compile anyway, so I suggest support for this is added in a seprate PR.

The solution above is for an extern const char*. Actually, https://docs.microsoft.com/en-us/cpp/cpp/selectany?view=msvc-170 might work as well. I can't really test this as MSVC does not compile anyway, so I suggest support for this is added in a seprate PR.
if (errStream) {
fprintf(stderr, "%c", *character);
} else {
printf("%c", *character);
}
}